From spencer.graves at prodsyse.com  Mon Jun 11 01:34:23 2012
From: spencer.graves at prodsyse.com (Spencer Graves)
Date: Sun, 10 Jun 2012 16:34:23 -0700
Subject: [Rd] Convert "\" to "/"?
In-Reply-To: <CA+xi=qa8h+MFZ1RAADYW-eXFTuaRVbcHcAo32KMBKzGnp6fAsQ@mail.gmail.com>
References: <4FD3FAF2.8020304@prodsyse.com>
	<CA+xi=qa8h+MFZ1RAADYW-eXFTuaRVbcHcAo32KMBKzGnp6fAsQ@mail.gmail.com>
Message-ID: <4FD52EFF.3040906@prodsyse.com>

Hi, Garrett:


On 6/9/2012 7:54 PM, G See wrote:
> One work around is to comment out the lines that `scan` reads.
>
>      (x<- back2ForwardSlash())
>      #c:\Users\
>      all.equal(x, '#c:/Users/')

       Thanks.  This works well enough to be useful.
>
> Or, you could pass a text arg through the dots
>
>      (x<- back2ForwardSlash(text="c:\\\users"))
>      all.equal(x, 'c:/users')


       This is not acceptable, because "sos-manual.pdf" displays ... 
'text="c:\\users"', which would likely confuse readers.


       Thanks again.
       Spencer
>
> HTH,
> Garrett
>
> On Sat, Jun 9, 2012 at 8:40 PM, Spencer Graves
> <spencer.graves at prodsyse.com>  wrote:
>> Hello, All:
>>
>>
>>           I have for years copied an address like "C:\Program
>> Files\R\R-2.15.0\library\MASS\scripts" from Windows Explorer into R, then
>> manually replaced "\" with "/".  I have a function to automate this added to
>> the development version of "sos".  However, it generates a warning in "R CMD
>> check" ("parse error:  unexpected input").  I have so far not found a way to
>> eliminate the warning without wrapping examples in "\dontrun" or making the
>> examples hard to understand;  neither of these alternatives are acceptable.
>>
>>
>>           The following is my current solution:
>>
>>
>> back2ForwardSlash<- function(nmax=1, what=character(), sep='\n', ...){
>>   x2<- scan(what=what, nmax=nmax, sep=sep, ...)
>>   x.<- gsub('\\', '/', x2, fixed = TRUE)
>> }
>> (x<- back2ForwardSlash())
>> c:\Users\
>> all.equal(x, 'c:/Users/')
>> # TRUE
>> x2.<- back2ForwardSlash(2)
>> c:\u\a b\n o
>> d:/pqr/
>> all.equal(x2., c('c:/u/a b/n o', 'd:/pqr/'))
>> # TRUE
>>
>>
>> QUESTION:  Might anyone have a better solution and / or simple, clear
>> examples that do not generate a warning in "R CMD check"?
>>
>>
>> NOTE:  In case you want to try this development version of "sos" including
>> this function, it is available via "svn checkout
>> svn://svn.r-forge.r-project.org/svnroot/rsitesearch/" or
>> install.packages('sos', repos = "http://R-Forge.R-project.org").
>>
>>
>>           Thanks,
>>           Spencer
>>
>>
>> p.s.  Prof. Ripley provided a way to do this on R-help several years ago.
>>   Unfortunately, I've been unable to find his solution.
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] Convert "\" to "/"?
Spencer Graves