[R] using paste and "\" to create a valid filename

roger bos roger.bos at gmail.com
Fri Aug 19 16:46:44 CEST 2005


Sometimes even the easy stuff is difficult (for me)... I want to get
input from different places to paste together an excel filename (so
you know I'm using windows) that I can open with RODBC.  I know about
using double "\" since its an escape character, but I get either 2 or
none, I can't get just one "\" where I need it.  See example code
below.  I am using R 2.1.0, but plan to upgrade soon.  Thanks in
advance to anyone who can help.

Roger


rankPath <- "R:\New Ranks\SMC\SMC"				
rankDate <- "20050819"				
rankFile <- paste(rankPath,rankDate,".xls", sep="")
rankFile
[1] "R:New RanksSMCSMC20050819.xls"


rankPath <- "R:\\New Ranks\\SMC\\SMC"				
rankDate <- "20050819"				
rankFile <- paste(rankPath,rankDate,".xls", sep="")
rankFile
[1] "R:\\New Ranks\\SMC\\SMC20050819.xls"




More information about the R-help mailing list