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

后端 未结 9 788
鱼传尺愫
鱼传尺愫 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:56

    For Ubuntu:
    Insert the following command into your .Rprofile file (usually in your home directory):

    setwd(Sys.getenv("PWD"))
    

    Now your default working directory will be whatever directory you launched R from. Keep in mind you can also set up default workspaces in different directories by saving your workspace image as .RData wherever you plan to launch R (startup sources .Rprofile before searching for .Rdata in the cwd).

提交回复
热议问题