[R] Converting shell("cd") to a string

Martin Maechler maechler at stat.math.ethz.ch
Fri Sep 26 17:31:38 CEST 2008

>>>>> "AR" == Arthur Roberts <aroberts99163 at yahoo.com>
>>>>>     on Fri, 26 Sep 2008 01:54:59 -0700 writes:

    AR> Hi, all,
    AR> Is there an R-command that will convert shell("cd") to a string, so  
    AR> that I can use it in the paste() command?

I'm pretty sure that for the specific case, you should use  
    setwd() and or getwd() 
which work platform-independently.

For the general case, note that shell() is windows-only whereas
the similar (but different!) function  system() is defined for
all platforms and it has a second argument 'intern' which when
set to TRUE returns the result "R internally", i.e. as a
character, so the answer to your first question might be

 system("cd", intern=TRUE)


More information about the R-help mailing list