1
path <- "C:/Users/R studio"

setwd("path/test")

# considering that R studio has directory named as test

This setwd function is not working. Can you please show how to use common path address as a variable in setwd so that if I want to change the directory to other subdirectories of the home path, then I can just append the new part at the end of the variable. Basically, I want to know how to use variable as a path in setwd.

1
  • assuming test is a directory in R studio setwd(paste0(path,"/test") or better yet just drop the path variable and pass the full path to setwd Commented Oct 21, 2016 at 18:24

1 Answer 1

1

you are including path inside the quotation marks..... so it's interpretting as a litteral "path". You want it to be a variable, so outside of the "".

So what you want to say is.

set path to whatever_path_is + "test".

You do this in R using the paste command... so:

setwd(paste(path,"/test",sep=""))

sep=seperator... so what should go between pastes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.