4

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. Does anyone know a quick evocation of the HOME variable in R?

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57
Zhang18
  • 4,031
  • 8
  • 43
  • 61

1 Answers1

2

Ah, I got it. it's just

data <- read.table("~/tmp/data.txt")
Zhang18
  • 4,031
  • 8
  • 43
  • 61