[R] How do you organize the objects you produced?
ligges at amadeus.statistik.uni-dortmund.de
Mon Mar 25 22:22:14 CET 2002
"Rikkoe at softhome.net" wrote:
> It would be nice to hear how you organize the R-objects you produced. I
> found almost nothing about that neither in the R-manuals nor in two books
> about S.
> For example I am trying to find out, how to load the functions that I have
> written and that are now saved in a .txt-file in a Windows directory. Is
> copying and pasting it to the RGui console really the only feasible way to
> do that? Constructing packages, similar to the ones included in the basic R
> system, is probably too complicated for a beginner like me, isn´t it?
Well, I wouldn't suggest to start learning R by creating your own
packages. But after some experiences it's a nice thing.
You are looking for
It's mentioned in section 1.10 of "An Introduction to R" (this manual is
really worth reading it completely; hint, hint!).
> I wonder why manuals and books just explain how to write functions, but not
> how to keep and to reload them. I have got a similar problem with my data. I
> understood (mistakenly?) that one can attach a Windows directory to the
> search path, so that every file inside this directory is known by R, without
> further need to specify the path.
"Usage: attach(what, pos = 2, name = deparse(substitute(what)))
Arguments: what, ``database''. This may currently be a data.frame or
list or a R data file created with save."
You can set your working directory (see below).
> So I tried:
> > attach("C:\\Temp",2)
> Error in load(file, envir) : unable to open file
> > search()
>  ".GlobalEnv" "file:C:\\Temp" "package:ctest" "Autoloads"
>  "package:base"
> Temp is a directory and includes a file named test.dat. I went on:
Well, as cited above: it's a directory, but neither a data.frame nor a
list nor a R data file.
> > file <- read.table("test.dat", header = TRUE, fill = TRUE)
> Error in file(file, "r") : cannot open file `test.dat'
> This last command only works when I use the RGui-menu to change my working
> directory to Temp.
> I feel I am using R as if cutting hair with a spoon. Do you know a nicer way
> to use it?
Instead of using the GUI, you can set your working directory with
Additionally, read.table() [and any other function] also works for whole
paths, e.g.: "c:/temp/test.dat".
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