[R] Querying the path separator?

Jonathan Greenberg greenberg at ucdavis.edu
Wed Jun 29 06:35:22 CEST 2011


Thanks Henrik, but as the help for this function states:

Note
The components are separated by / (not \) on Windows.

, the slashes it uses are incorrect for use in a CMD window on a
Windows box (they need to be \ but file.path uses /).  I suppose I can
do a query as to whether the platform is Windows (in which case use \)
or other (in which case use /) -- there isn't a more "clever" way of
doing this?

--j

On Tue, Jun 28, 2011 at 7:10 PM, Henrik Bengtsson <hb at biostat.ucsf.edu> wrote:
> See file.path().
>
> /Henrik
>
> On Tue, Jun 28, 2011 at 6:59 PM, Jonathan Greenberg
> <greenberg at ucdavis.edu> wrote:
>> Hopefully this is a pretty easy fix -- I need to have R query the path
>> separator for some code I'm trying to write (it involves using a
>> system() call) -- the call requires a path and a wildcard, e.g.:
>>
>> command="mycommand /path/to/*.files" in the case of unix or,
>> command="mycommand.exe C:\\path\\to\\*.files" on a windows box
>>
>> System.which is working correctly, so the "mycommand" vs
>> "mycommand.exe" part is working fine.  The issue is that the /path/to
>> should be set to getwd(), but this strips the trailing path separator.
>>  How do I go about querying the correct path separator for the system,
>> so I can include it in a paste command (via sep=)?  Thanks!
>>
>> --j
>>
>> --
>> 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
>>
>> ______________________________________________
>> 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