After module 3, you should be able to…
The internal file structure of the computer is completely nested!
Computer scientists call this the “file tree”.
\
”), but R interprets these as”escape” characters. So you must replace the backslash with forward slashes (“/”) or two backslashes (“\\
”)From Wiki
An absolute or full path points to the same location in a file system, regardless of the current working directory. To do that, it must include the root directory. Absolute path is specific to your system alone. This means if I try your code, and you use absolute paths, it won’t work unless we have the exact same folder structure where R is looking (bad).
By contrast, a relative path starts from some given working directory, avoiding the need to provide the full absolute path.
You want to set you code up based on relative paths. This allows sharing of code, and also, allows you to modify your own file structure (above the working directory) without breaking your own code.
Remember above “Many people recommend not setting a directory in the scripts, rather assume you’re in the directory the script is in.” To do so, go to Session –> Set Working Directory –> To Source File Location
RStudio will show the code in the Console for the action you took with your cursor. This is a good way to learn about your file system how to set a correct working directory!
If you have not yet saved a “source” file, it will set working directory to the default location.Find the Tool Menu in the Menu Bar -> Global Opsions -> General for default location.
To change the working directory to another location, find Session Menu in the Menu Bar –> Set Working Directory –> Choose Directory`
Again, RStudio will show the code in the Console for the action you took with your cursor.
setwd()
and getwd()
are useful for identifying and manipulating the working directory.These are the materials we looked through, modified, or extracted to complete this module’s lecture.