[R] Querying the path separator?

Jonathan Greenberg greenberg at ucdavis.edu
Thu Jun 30 21:32:28 CEST 2011


Unfortunately, no.  .Platform$file.sep on a windows box is the "/".
For this DOS program it needs to be the "classic" backslash.

Ok, we'll hack this a bit (query the platform and test if it is
windows), but now I'm running into escape character problems.  Given:

files1="*.las"
files1_formatted=file.path(getwd(),files1)
files1_formatted
[1] "X:/pathto/*.las"

I want files1_formatted to read:
"X:\pathto\*.las"

Using:
sub("/","\",files1_formatted)
Doesn't work (in fact, its not a complete statement -- I assume since
its waiting for something to follow the / ).  What's the trick with
this?

--j



On Tue, Jun 28, 2011 at 11:05 PM, Berend Hasselman <bhh at xs4all.nl> wrote:
>
> Jonathan Greenberg wrote:
>>
>> The problem is that I'm trying to create a path to use with a system()
>> call, and the command window will not work with the forward slash,
>> only with the standard backslash.  I do understand that within R it
>> will work with either way, but not via the system call.  I'm trying to
>> create a "generic" system() call that will work with an external
>> executable that is available on both windows and unix machines.
>>
>
> Would .Platform$file.sep help you?
> I can't test this.
>
> Berend
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Querying-the-path-separator-tp3631806p3632161.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>



-- 
Jonathan A. Greenberg, PhD
Assistant Project Scientist
Center for Spatial Technologies and Remote Sensing (CSTARS)
Department of Land, Air and Water Resources
University of California, Davis
One Shields Avenue
Davis, CA 95616
Phone: 415-763-5476
AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307



More information about the R-help mailing list