Please help! New user can't set working drive on Windows

I am brand new to RStudio. My course provides instructions for setting up the working drive in the console of RStudio:

setwd("C:/Users/Default.DESKTOP-L72OCEF/Document/STAM200")

I get the error message:

Error in setwd("/Users/Default.DESKTOP-L72OCEF/Document/STAM200") :
cannot change working directory

When I type getwd, I get the following back:

getwd
function ()
.Internal(getwd())
<bytecode: 0x00000137266c3738>
<environment: namespace:base>

I'm working on windows 10. I'd really appreciate some help getting this working drive set up so that I can work through my course assignment this weekend!

Thanks!

I think the problem is that you refer to a directory named Document and it is probably called Documents, with a final "s".

The proper syntax is

getwd()

In R getwd() is a function. The command getwd says : Print out the code for the function. In order for a function to "work" it needs the (). try set.seed versus set.seed(123). BTW, set.seed() gives an error.

1 Like

sorry, that was a typo. I tried it a bunch of times with the directory named "documents", not "document as I typed. I fixed the typo, and it still doesn't work

Thanks. Are you able to dumb it down even more? I'm a real beginner here, and not that tech savvy!

should be getwd(), although that may not be that is all that is in the way.

That was about as dumb as it gets :grinning:

This may help.

Assuming a working version of R and RStudio if you issue the command

getwd()

it should tell you what directory (aka "folder") that you are currently using.

For example if I do

 getwd()

it comes back and tells me that I am using the directory (folder)

/home/john/RJunk

This is in Linux so the path_name will not be the same as on a Windows machine. It's been a long time since I used Windows but you likely would get something along the lines of

C:/megan/my_holidays/tenerife

Once you know where you are you can work back to where you should be. Go back to C:/megan and see what folders you have.

Alternatively Windows must have a search function! Go to C:/megan and do a search for STAM200. You should get a path there. I am sorry not to be of more help but I have not used Windows in roughly 15 years and have forgotten most of its horrors commands.

BTW I just noticed this Free Four Week Introduction to Data Science Starting January 23

He references his on-line book Preceptor’s Primer for Bayesian Data Science: Using the Cardinal Virtues for Inference which after a couple of hours perusal looks like a great resource. I am not sure it will help with your problem but it really looks useful. Anyway, back to reading.

Slow and steady. When I run into problems like these, I start to search for and answer, even after using R and RStudio for 15 years and other programs from Before Times, when only mainframes roamed the Earth.

When that happens, I have to force myself to step back and see if I'm looking for an answer to the right question, starting from the top

Can I see this in whatever Windows uses these days for a file browser? Is it a directory and not a file? What kind of file is in it? Can you open the file with another app (is it readable?)

When this is sorted consider using the RStudio menu to create a new project, create a folder data with the data you will be using, install.packages("here") and when you open the project it will open the correct file and no need to setwd(). Then, when you need, say, to open a csv file

my_df <- read.csv(here::here("data/my.csv")

While I agree in principle' does not

setwd("C:/Users/Default.DESKTOP-L72OCEF/Document/STAM200")

imply that something in the course has, supposedly, already created

"C:/Users/Default.DESKTOP-L72OCEF/Document/STAM200")

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.