How to get R to recognize your working directory as its working directory?

后端 未结 9 728
鱼传尺愫
鱼传尺愫 2020-12-25 13:27

I use R under Windows on several machines.

I know you can set the working directory from within an R script, like this

setwd(\"C:/Documents and Setti         


        
9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-25 13:47

    You could use an environmental variable. This can work with Sys.getenv() and Sys.setenv(). For instance:

    > Sys.setenv(R_TEST="testit")
    > Sys.getenv("R_TEST")
      R_TEST 
    "testit" 
    

    If you sent the variable in your script, you should be able to access it from within, and then call setwd() on that output.

提交回复
热议问题