How to Get, Set or Change your working directory in R

1

If you are just starting out in R it’ll be important to know how to determine your working directory or how to find the files you may have saved. Luckily getting, setting or changing your working directory in R is easy and should be part of any cheat sheet you might be keeping handy.


> setwd("..")
> getwd()
> setwd("R1")

Let’s go through these one by one.

A double-dot (..) as setwd(“..”) is used to move up a folder from your current directory.

To find your current directory type getwd().

To go to a specific directory add the directory between the quotes. See above where “R1” was used after the setwd.

You can also move a few levels in your directory by using the following structure: setwd(“./parent/child”).

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here