0

mission on online course:

Download this RData file to your working directory. Then load the data into R with the following command:

load("skew.RData")

so I have downloaded it to my computer but where is my working directory? or how do I load the downloaded file to Rstudio

  • Your working directory is the directory that your code is running in. If you’re using projects in RStudio, it’s the project directory. If you’re not using projects … you should start using projects. But you can find out the working directory via `getwd()`. – Konrad Rudolph Jul 09 '20 at 09:40

2 Answers2

0

You can see your working directory by executing getwd(). In order to load the data you need to change it to the folder path where the data is stored.

setwd("C:/your/path")
load("skew.RData")
WhoAmI
  • 148
  • 1
  • 8
  • You almost certainly *do not* want to use `setwd`, or hard-code paths. – Konrad Rudolph Jul 09 '20 at 09:39
  • Do you mean that using `setwd()` is bad practice as stated [here](https://stackoverflow.com/questions/13770304/risks-of-using-setwd-in-a-script) or are there any other risks in using `setwd()` in combination with `load()`? – WhoAmI Jul 09 '20 at 10:12
  • It’s for these reasons, but Ben Bolkers is too lenient, and pretends that using `setwd` is less bad than it actually is. Here’s a more honest take: https://www.tidyverse.org/blog/2017/12/workflow-vs-script/ – Konrad Rudolph Jul 09 '20 at 12:43
0

You can set you working directory in RStudio on the right side manually and then save the files there and open them like :

load("skew.RData")

If your file is saved somewhere else, you should define the path to it:

load("path/to/your/file/skew.RData")