I am trying to take two character vectors:
directory <- "specdata"
id <- 1
and read the data in from the file that they would “point” to: ie:
data <- read.table(paste(directory,"\\",id,".csv", sep="")
The problem is in the result of paste and the “\”. I am trying to get it to return "specdata\1.csv" however it returns "specdata\\1.csv" which is not the same.
To no avail, I have also tried:
- using a single-slash
"\" - using single quotes like
'\\' - using single quotes like
'\' - changing sep =
'\' - changing sep =
'\\' - changing sep =
"\" - changing sep =
"\\" - using the c() function first like
code:
fileNameAndPath <- c(directory,"\",id,".csv")
data <- read.table(fileNameAndPath)
You should use
file.pathinstead (it is independent of your platform):