Working Directories

Not sure I am using the correct category, but here goes. My first question. I have been doing the Google Analytics course in R and have been stymied for the last few days trying to set my directory to my MacBook Air and R won't let me. What's wrong?

#> this is the code I have used

> getwd()
[1] "/cloud/project"
> setwd(":///Users/tloewen/Downloads/")
Error in setwd(":///Users/tloewen/Downloads/") : 
  cannot change working directory
> setwd("/Users/tloewen/Downloads/")
Error in setwd("/Users/tloewen/Downloads/") : 
  cannot change working directory

#> what am I doing incorrectly?

If you are using Rstudio in the Cloud, i.e. through a webbrowser,
the device is running over there, and does not have your local device's drives mapped to it.

You can download RStudio and use that application on your Macbook Air, rather than use Rstudio Cloud, if you want your working directory to be local to your laptop.

Otherwise, be content with your clouds working directory being where it is, and ephemeral. If you have a small asset on your local device you want to transfer you can do an upload from your local device to the cloud environment.

1 Like

Thank you for responding. I have downloaded R on my Mac but it doesn't have the same interface that Posit does and while it is easy to get it to use my directory, it isn't functional like Posit Cloud. I have Posit Cloud set up using my Chrome web browser. You say I can't point to my local directory, but I recall that I did it once... Can't repeat it. In any event, I am studying for my final and wanted to practice using the Chocolate and Tea data. I found it and downloaded it to my laptop but do not know how to get it into Posit Cloud. Got any further ideas? Thanks for making me think this through.

In the lower right pane of your Posit Cloud project, click the Files tab. Then look for the Upload button in that pane. Click that and you can browse to your file and upload it to your project.

You should also install RStudio Desktop (as well as R) and it will look (virtually) identical to Posit Cloud.

RStudio Desktop - Posit

I suggest considering using a project oriented workflow, as described in this blog post, because "The chance of the setwd() command having the desired effect – making the file paths work – for anyone besides its author is 0%.":

1 Like

Thank you all for chipping in. All posts have been helpful.