From Kurt.Hornik@ci.tuwien.ac.at  Fri Sep 24 15:13:51 1999
From: Kurt.Hornik@ci.tuwien.ac.at (Kurt Hornik)
Date: Fri, 24 Sep 1999 16:13:51 +0200 (CEST)
Subject: Private data libraries (idea & trick)
In-Reply-To: <x2iu5388wk.fsf@blueberry.kubism.ku.dk>
References: <x2iu5388wk.fsf@blueberry.kubism.ku.dk>
Message-ID: <14315.34591.572539.50534@fangorn.ci.tuwien.ac.at>

>>>>> Peter Dalgaard BSA writes:

> It has been annoying me for a while that data in user areas are more
> difficult to handle than those in the packages. 

> Especially for beginners, it would be very handy to be able just to
> say "data(mydata)", rather than
> "mydata<-read.table('mydata.txt',header=T)"

> What just occurred to me was that the following hack actually works:

> Type

> library('.',lib.loc='.')

> and everything in ./data behaves as if it were in a package. 

> Another interesting hack is that one can do this:

> [pd@blueberry data]$ cat > file.txt
> a b
> 1 2
> 3 4
> [pd@blueberry data]$ cat > file.R
> file<-transform(read.table('file.txt',header=T),
>     b=factor(b,levels=1:4,labels=letters[1:4]))

> and then from inside R, get the dataframe with factor recoding and
> everything as

>> data(file)
>> file
>   a b
> 1 1 b
> 2 3 d

> Question: Should we perhaps clean this up a little and formalize it?

Actually, this works in directories different from the current one as
well, as the working directory is changed temporarily.  However, someone
pointed out that this is not thread-safe, so we should be careful about
announcing this feature.

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Private data libraries (idea & trick)
Kurt Hornik