[R] Keep value lables with data frame manipulation

From: Jol, Arne <Arne.Jol_at_Unilever.com>
Date: Thu 13 Jul 2006 - 02:41:42 EST


Dear R,

I import data from spss into a R data.frame. On this rawdata I do some data processing (selection of observations, normalization, recoding of variables etc..). The result is stored in a new data.frame, however, in this new data.frame the value labels are lost.

Example of what I do in code:

# read raw data from spss
rawdata <- read.spss("./data/T50937.SAV",

        use.value.labels=FALSE,to.data.frame=TRUE)

# select the observations that we need

diarydata <- rawdata[rawdata$D22==2 | rawdata$D22==3 | rawdata$D22==17 | rawdata$D22==18 | rawdata$D22==20 | rawdata$D22==22 |

                         rawdata$D22==24 | rawdata$D22==33,]

The result is that rawdata$D22 has value labels and that diarydata$D22 is numeric without value labels.

Question: How can I prevent this from happening?

Thanks in advance!
Groeten,
Arne



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 13 02:47:51 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 13 Jul 2006 - 06:20:25 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.