[R] access other directories/ setwd

Prof Brian D Ripley ripley at stats.ox.ac.uk
Fri Jun 22 08:28:04 CEST 2001


On Fri, 22 Jun 2001, S.McClatchie wrote:

> Colleagues
>
> ----------------------------------
> System info:
> Version 1.2.3  (2001-04-26) on NT
> ESS v. 5.1.18 using emacs ver. 20.4
>
> ----------------------------------
> This message is a follow up to a previous enquiry where Patrick Connolly
> and Brian Ripley both provided helpful suggestions.
>
> I want to be able to access objects in another subdirectory than that
> where I start R. The startup directory (\\biomass spectrum) currently has
> no objects in it. The other directory (\\opc) has lots of objects. I need to
> see these, so I tried attaching the .Rdata in \\opc\\R-src. Patrick
> suggested that it was called _RData in windows, but it does seem to be
> called .RData.

It is indeed .RData (although Windows will match .Rdata too).

> > getwd()
> [1] "h:\\DATA\\nov99_TAN9913\\biomass spectrum"
> > objects()
> character(0)
> > setwd("h:\\DATA\\nov99_TAN9913\\opc")
> NULL
> > getwd()
> [1] "h:\\DATA\\nov99_TAN9913\\opc"
> > objects()
> character(0)
> > attach("h:\\DATA\\nov99_TAN9913\\opc\\R-src\\.RData")
> > objects()
> character(0)
> >

You need to either load() the objects, or to attach the .RData file.
In the latter case the objects are available, but not in the user's
workspace.  So (without changing the working directory)

attach("h:\\DATA\\nov99_TAN9913\\opc\\R-src\\.RData")
ls(2)

should show you the objects, and they are in the search path as

search()

will show.



-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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