How to call the R home directory in building a file name?

I am using R under Windows XP. He selected the HOME variable from the window, which,

> Sys.getenv("R_USER") R_USER "H:" 

However, how to quickly use this variable in a file name? In particular, if I have a file stored in H:/tmp/data.txt . How do I create the following command?

 data <- read.table("$R_HOME/tmp/data.txt") 

It obviously didn't work.

The only way to make it work:

 data <- read.table(paste(Sys.getenv("R_USER"), "/tmp/data.txt", sep = "")) 

It is so cumbersome that I have to believe that there is an easier way. Does anyone know the quick resurrection of the HOME variable in R?

+4
source share
1 answer

Ah, I get it. it's simple

 data <- read.table("~/tmp/data.txt") 
+2
source

All Articles