I'm using R under Windows XP. It picked up the environmental variable HOME from windows which is
> Sys.getenv("R_USER")
R_USER
"H:"
However, how can I use that variable quickly in a file name? In particular, if I have a file stored at H:/tmp/data.txt
. How should I construct the following command?
data <- read.table("$R_HOME/tmp/data.txt")
That one clearly didn't work.
The only way I got it to work is the following:
data <- read.table(paste(Sys.getenv("R_USER"), "/tmp/data.txt", sep = ""))
which is so cumbersome that I have to believe there is an easier way. So if you know a quick evocation of the HOME variable in R, please let me know!