Skip to content
Back to formatted view

Raw Message

Message-ID: <18653.90.275284.148611@stat.math.ethz.ch>
Date: 2008-09-26T15:31:38Z
From: Martin Maechler
Subject: Converting shell("cd") to a string
In-Reply-To: <4C4A6CA4-3584-4921-9F05-81AC336F4978@yahoo.com>

>>>>> "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)

Martin