[R] unix

ben@zoo.ufl.edu ben at zoo.ufl.edu
Mon Nov 6 16:52:47 CET 2000

  I'd like to point out a potential confusion. Although the advice about
system() is technically correct, for the particular case of changing
directories you probably want to use getwd/setwd [I think system() spawns
its own shell, so changing directories with system() isn't persistent].  
For example:

> getwd()   ## start in my home directory
[1] "/home/ben"
> system("cd ..")  ## this executes OK but ...
> getwd()
[1] "/home/ben"    ## I'm still in the same working directory
> setwd("..")      ## this is the way to change working directory
> getwd()          ## now I've moved up one
[1] "/home"

system("pwd") would do the same thing as getwd(), but is specific to Unix
(whereas getwd() should also work on Windows etc.)

  For my two cents, the "shorthand" command that I'd like to have in R
would be a shortcut for referring to .Last.value like %, %% in Maple ...
might be hard to find a special character that's not already used for
something, though.

On 6 Nov 2000, Peter Dalgaard BSA wrote:

> Meriema Belaidouni <meriema at info.univ-angers.fr> writes:
> > ls
> > cd ..
> > 
> > In matlab this possible by adding "!"
> > !ls
> > !cd ..
> Use system("ls"). We've had the "!" convention at some point, but as I
> remember it, people got tired of having it kick in unexpectedly where
> logical "not" was intended, and we decided that it was probably a bad
> idea to have a syntactically correct R expression do something
> completely different when it happened to sit at the beginning of a line...

318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list