[R] How to do platform independent system calls?
    S Ellison 
    S.Ellison at LGCGroup.com
       
    Tue Apr  2 19:17:58 CEST 2013
    
    
  
> > 2) Is there a way to generate platform independent paths? So that 
> > "path/2/input.tbl" on *nix systems becomes "path\2\input.tbl" on a 
> > Windows system?
> 
> R already does that automatically. 
Clarification. R does that automatically _for paths used by R_ (including, on my system, the path to command in system(command) ) but NOT for path or file arguments supplied to that system command. So R correctly runs cmd.exe when specified as system("c:/windows/system32/cmd.exe") but if you wanted to supply a path as an  argument R does not know that the argument is a path and wisely doesn't treat it as one.
So (on win XP and using R 2.15.3) 
system("c:\\windows\\system32\\cmd /c dir c:\\windows\\system32\\d*.*", intern=T)
#and
system("c:/windows/system32/cmd /c dir c:\\windows\\system32\\d*.*", intern=T)
#both work but 
system("c:/windows/system32/cmd /c dir c:/windows/system32/d*.*", intern=T)
	#does not
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
    
    
More information about the R-help
mailing list