5.2 Navigate the tree of directory with the R console
- Get the path of the current directory (know where you are working at the moment) with getwd (get working directory):
Hit Enter/Return to execute getwd() in the R console.
- Change working directory with setwd (set working directory)
(in a Windows or MAC OS system, you would typically double-click to reach sub-directories).
Here we use commands/fonctions in the R console:
Go to a directory giving the absolute path (the entire address):
Same as:
Go to a directory giving the relative path. For example, if you are in Rcourse, you can either go to Module1 using the absolute path:
or the relative path:
You are now in: “~/Rcourse/Module1” (check it with getwd() !).
Move one directory “up” the tree:
You are now in: “~/Rcourse”
HANDS-ON
- Execute the following command in the R console:
- Where are you now? (use getwd())
- Find your way back to the Module1 folder