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

From: Spencer Graves <spencer.graves_at_prodsyse.com>
Date: Sat, 09 Jun 2012 18:40:02 -0700


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 Received on Sun 10 Jun 2012 - 01:42:28 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 10 Jun 2012 - 23:42:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive