I wrote a little routine to convert multiple spss data files (as data frames) 
to R data files.  The code is as follows:
#
list=dir(pattern=".sav")
library(foreign)
for (i in 1:length(list)){
# The saved data frame will be dat
dat=read.spss(list[i],to.data.frame=TRUE)
name=substring(list[i],1,nchar(list[i])-4)
rname=paste("../R/",name,".rda",sep="")
# This uses dat for the saved dataframe rather than name
save(dat,file=rname)
}

This works just fine, but the data frames are all named dat when loaded into 
Rcmdr. It is not a problem to do an assignment at load time
from the command line as in catnip=load("catnip.rda"), but Rcmdr uses the data 
frame name saved in the compressed .rda file upon loading.

My variable "name" contains the string for the dataframe name I would like to 
use.  I just can't figure out how to assign this name to the dat dataframe in 
the context of my loop.

Any hints?

Thanks,
Rob Baer


        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to