Christoph Scherber
2011-Jan-14 14:32 UTC
[R] Extract Crawley´s datasets and pack them into a new package
Dear all, I have a seemingly easy question but couldn?t find a solution so far: I?d like to have all datasets from Crawley?s "R Book" in an own package, so that I can easily access them. Let?s assume they are all saved on C: in the following directory: setwd("C:\\Crawleydata") Now I am loading all datasets using lapply: ### LL<-list.files("C:\\Crawleydata",pattern = "\\.txt$") LL2<-as.list(LL) names(LL2)<-LL LL3<-lapply(LL2,function(x)try(read.table(x,header=T,sep="\t"))) ### So far, so good; now that I have all files in LL3, how do I move them out to the "data" path in a newly created library? I know that "package.skeleton()" should do the job, but somehow I got stuck here... Many thanks for your help! Best wishes Christoph [using R 2.12.1 on Windows XP] -- *PLEASE NOTE OUR NEW POSTAL ADDRESS!* Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Grisebachstr. 6 D-37077 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1
Uwe Ligges
2011-Jan-14 16:43 UTC
[R] Extract Crawley´s datasets and pack them into a new package
More or less untested without using package.skeleton after preparing the package directories: datapath <- "c:/packagename/data" within(LL3, for(i in ls()) save(list=i, file=file.path(datapath, paste(i, ".RData", sep="")))) or with package.skeleton: package.skeleton("packagename", path="c:/", environment=as.environment(LL3)) Best, Uwe Ligges On 14.01.2011 15:32, Christoph Scherber wrote:> Dear all, > > I have a seemingly easy question but couldn?t find a solution so far: > > I?d like to have all datasets from Crawley?s "R Book" in an own package, so that I can easily access them. > > Let?s assume they are all saved on C: in the following directory: > > setwd("C:\\Crawleydata") > > Now I am loading all datasets using lapply: > > ### > > LL<-list.files("C:\\Crawleydata",pattern = "\\.txt$") > LL2<-as.list(LL) > names(LL2)<-LL > > LL3<-lapply(LL2,function(x)try(read.table(x,header=T,sep="\t"))) > ### > > So far, so good; now that I have all files in LL3, how do I move them out to the "data" path in a newly created library? > > I know that "package.skeleton()" should do the job, but somehow I got stuck here... > > Many thanks for your help! > > Best wishes > Christoph > > [using R 2.12.1 on Windows XP] > > > > > > > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.