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

From: Berton Gunter <gunter.berton_at_gene.com>
Date: Sat 20 Aug 2005 - 01:11:33 EST


... and you can see that the "\\" is correct by cat(rankFile) instead of print(rankFile), which is what entering the variable at the prompt actually does.

"The business of the statistician is to catalyze the scientific learning process." - George E. P. Box    

> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Uwe Ligges
> Sent: Friday, August 19, 2005 8:04 AM
> To: roger bos
> Cc: r-help@stat.math.ethz.ch
> Subject: Re: [R] using paste and "\" to create a valid filename
>
> roger bos wrote:
>
> > 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"
>
>
> This is perfect, "\" is *printed* escaped, hence for file
> access you can
> perfectly use this character vector.
>
> Uwe Ligges
>
>
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Aug 20 01:15:28 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:34:15 EST