Ebert,Timothy Aaron
2025-Dec-08 14:15 UTC
[R] Windows standard interface: change working dorectory
People who use computers should understand file names. It does not matter if you
call them folders or directories they are the same animal.
I have a file called "my_file"
Where does it live? "On my computer" is like saying my mailing address
is "Earth."
All files have a memory location in your computer where the computer can find
the file contents. All names consist of two, but more commonly three parts:
location, name, type. These answer "where is the file," "what is
it called," and "what kind of file?" The format for location is
disk drive followed by an ordered list of (directories or folders) from outer to
innermost. I am on Windows, so for me this looks like c://dir1/dir2/dir3/. In
words, I look on my hard drive named "C" and will find a directory
called dir1. Inside dir1 will be dir2 and inside that will be dir3 where I can
find my file.
File names typically end with a period followed by the type of file. .xlsx for
an Excel file, .txt for a text file, .csv for comma separated values file, docx
for a Microsoft word file. Most of the time on Windows the extension is hidden,
and the path is shown at the top of the window. This was all very obvious in the
old days working with DOS, but windows made things "easy" and took
this away from the default output. In any case, files are all saved something
like this: "c://dir1/dir2/dir3/my_file.docx".
I have multiple projects in R. I could change the working directory in R
multiple times each day and try to keep up. I am bad at that. My solution is
that I never change the working directory, so all read and write statements
include the full file name, path and all. I can then switch between projects and
not worry about where to read or save things and I do not sometimes get files
saved in strange places. One could set the working directory at the start of
each program, but that assumes that I want to always start working at the top of
each program. I have not had much luck with that approach.
I sometimes write software for others to use. In this case I give users a popup
window where they select their file using a graphical interface and then the
program extracts the path from where the user got the file. This path is then
added to the file name the user provides to save output. In this way I do not
have to worry about the difference between
"c://dir1/dir2/dir3/my_file.docx" and
"c:\\dir1\dir2\dir3\my_file.docx"
Regards,
Tim
-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of Calboli
Federico (LUKE)
Sent: Monday, December 8, 2025 6:22 AM
To: r-help at r-project.org
Subject: [R] Windows standard interface: change working dorectory
[External Email]
Hello,
I need to provide the simplest possible indication to R users with either
windows or macos machines on how to change working directory. Using setwd() will
not work because I cannot trust them to even understand the concept of working
directory.
On macos it is possible to have a GUI menu (the standard R GUI) that would allow
the users to "click their way to where their data files are", is there
such facility for the windows R GUI (the out-of-the-box one)? I have no access
to windows machines, so I cannot check, but I am sure some people will use a
windows laptop.
F
--
Federico Calboli
Erityisasiantuntija, tutkimusrahoitus
Palveluryhm?t
Luonnonvarakeskus
[[alternative HTML version deleted]]
Calboli Federico (LUKE)
2025-Dec-08 14:24 UTC
[R] Windows standard interface: change working dorectory
As much I might agree with you in theory, people here are just using R to
produce some graphs using one line of code I generated, so they can do the job
they are paid to do (which is not computing). Producing said graph and its
permutations would be more complex in any other way, and I want to make sure the
instructions I printed out for them are as simple, accessible, and require the
least amount of supervision.
F
--
Federico Calboli
Erityisasiantuntija, tutkimusrahoitus
Palveluryhm?t
Luonnonvarakeskus
People who use computers should understand file names. It does not matter if you
call them folders or directories they are the same animal.
I have a file called "my_file"
Where does it live? "On my computer" is like saying my mailing address
is "Earth."
All files have a memory location in your computer where the computer can find
the file contents. All names consist of two, but more commonly three parts:
location, name, type. These answer "where is the file," "what is
it called," and "what kind of file?" The format for location is
disk drive followed by an ordered list of (directories or folders) from outer to
innermost. I am on Windows, so for me this looks like c://dir1/dir2/dir3/. In
words, I look on my hard drive named "C" and will find a directory
called dir1. Inside dir1 will be dir2 and inside that will be dir3 where I can
find my file.
File names typically end with a period followed by the type of file. .xlsx for
an Excel file, .txt for a text file, .csv for comma separated values file, docx
for a Microsoft word file. Most of the time on Windows the extension is hidden,
and the path is shown at the top of the window. This was all very obvious in the
old days working with DOS, but windows made things "easy" and took
this away from the default output. In any case, files are all saved something
like this: "c://dir1/dir2/dir3/my_file.docx".
I have multiple projects in R. I could change the working directory in R
multiple times each day and try to keep up. I am bad at that. My solution is
that I never change the working directory, so all read and write statements
include the full file name, path and all. I can then switch between projects and
not worry about where to read or save things and I do not sometimes get files
saved in strange places. One could set the working directory at the start of
each program, but that assumes that I want to always start working at the top of
each program. I have not had much luck with that approach.
I sometimes write software for others to use. In this case I give users a popup
window where they select their file using a graphical interface and then the
program extracts the path from where the user got the file. This path is then
added to the file name the user provides to save output. In this way I do not
have to worry about the difference between
"c://dir1/dir2/dir3/my_file.docx" and
"c:\\dir1\dir2\dir3\my_file.docx"
Regards,
Tim
-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of Calboli
Federico (LUKE)
Sent: Monday, December 8, 2025 6:22 AM
To: r-help at r-project.org
Subject: [R] Windows standard interface: change working dorectory
[External Email]
Hello,
I need to provide the simplest possible indication to R users with either
windows or macos machines on how to change working directory. Using setwd() will
not work because I cannot trust them to even understand the concept of working
directory.
On macos it is possible to have a GUI menu (the standard R GUI) that would allow
the users to "click their way to where their data files are", is there
such facility for the windows R GUI (the out-of-the-box one)? I have no access
to windows machines, so I cannot check, but I am sure some people will use a
windows laptop.
F
--
Federico Calboli
Erityisasiantuntija, tutkimusrahoitus
Palveluryhm?t
Luonnonvarakeskus
[[alternative HTML version deleted]]
[[alternative HTML version deleted]]