Skip to content
Prev 157283 / 398506 Next

Converting shell("cd") to a string

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)

Martin