[R] r script

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Nov 6 11:44:05 CET 2008


2008/11/6 Paul Hiemstra <p.hiemstra at geo.uu.nl>:

>> How can execute a bash command inside the script, like the command for
>> change the directory (cd)?

> ?system

 The system function won't work for changing the working directory of R though:

> getwd()
[1] "/home/rowlings"
> system("cd /")
> getwd()
[1] "/home/rowlings"

 For that you need R the function setwd(newWorkingDirectory).

Barry



More information about the R-help mailing list