The tilde expression is not working on my RStudio! I am using a windows 10 OS.
Update : After looking more carefully(thanks to Dason) It seems the "~" is pointing to "user/Documents/" rather then "user/". is there any work around?
Any help?
As you found out yourself, R's ~
points to your documents folder. An easy way to work around this could be to start the paths you want to reference with ~/../
. So your setwd
call would look like this:
setwd('~/../{your actual path from home}')
The same problem occurs on my Windows PC. I do not have a Linux machine at hand to test whether it is the same there. R gets this variable from the R_USER
environment variable. You can override that in your R environment startup file. This issue is not specific to RStudio and also occurs when you start an R session from the command line.
At startup, R looks for Renviron.site
in the R_HOME
directory. Open and edit it
file.edit(file.path(Sys.getenv('R_HOME'), 'etc', 'Renviron.site'))
Define R_USER
in that file with the path you want '~'
to point to:
R_USER = 'C:/Users/USERNAME'
References: R for Enterprise: Understanding R’s Startup
来源:https://stackoverflow.com/questions/34400903/tilde-expression-not-functioning-in-r