Skip to content

How do you organize the objects you produced?

3 messages · Rikkoe@softhome.net, Uwe Ligges, Brian Ripley

#
Hello!

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?

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. So I tried:
Error in load(file, envir) : unable to open file
[1] ".GlobalEnv"    "file:C:\\Temp" "package:ctest" "Autoloads"
[5] "package:base"


Temp is a directory and includes a file named test.dat. I went on:
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?

Michael


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
"Rikkoe at softhome.net" wrote:
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 
 source()

It's mentioned in section 1.10 of "An Introduction to R" (this manual is
really worth reading it completely; hint, hint!).
Indeed, mistakenly.
"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).
Well, as cited above: it's a directory, but neither a data.frame nor a
list nor a R data file.
Instead of using the GUI, you can set your working directory with
 setwd("c:/temp")
Additionally, read.table() [and any other function] also works for whole
paths, e.g.: "c:/temp/test.dat".

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Mon, 25 Mar 2002, Rikkoe at softhome.net wrote:

            
They do explain about packages.
No.
Um, a book called `S Programming' does.