On Tue, 29 Sep 2009, edche...@gmail.com wrote:


I have chances to work with both linux based and win based R codes. And as you all know in linux, the file directories use "/" and win uses "\\". Is there a function like sub or gsub that could substitute those slashes automatically?

See ?chartr, and you can also use gsub(fixed = TRUE).

But as both the R and rw FAQs tell you, your assertion about 'win' is incorrect for modern Windows: the Windows system functions accept either slash or backslash, as do all but a few badly-written Windows applications.

A word of warning: the ASCII representation of \ is both a character in Windows DBCS encodings (used for CJK languages, it is rendered as the Yen symbol in most DBCS fonts) and a trail byte, and you need to be very careful with substitutions. We have had reports of both gsub and chartr mangling Chinese file names, although it is likely they were not in a Chinese locale and it was before many Unicode-related changes in R under Windows.

Thanks!

Edward Chen
Email: tke...@msn.com
Cell Phone: 510-371-4717

--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to