I read in spss files using haven's read_spss. Each column then gets attributes 
assigned named
label - a long description of the variable
class -" labelled"
labels --- answer labels i.e. 1=Male, 2=Female
 example -
> attributes(KPTV[[3]])
$label
[1] "DERIVED: Survey language"

$class
[1] "labelled"

$labels
English Spanish 
      1       2 

However, if I subset the data.frame  e.g. MassTV<-KPTV[row selection logic,] 
the label attribute disappears

attributes(MassTV[[3]])
$labels
English Spanish 
      1       2 

$class
[1] "labelled"

If I use dplyr to filter the data I simply get an ERROR that the label 
attribute is not supported.

> MassTV<-filter(KPTV,KPTV$MNO %in% KPMass$`KPMain$mno`)
Error: column 'MNO' of type numeric has unsupported attributes: label

Any ideas on how I can preserve the label attribute (i.e. the long description 
of the variable name?)

Thanks for any help,

Mike

--
W. Michael Conklin
Executive Vice President
Marketing & Data Sciences - North America
GfK | 8401 Golden Valley Road | Minneapolis | MN | 55427
mike.conk...@gfk.com 
T +1 763 417 4545 | M +1 612 567 8287 
www.gfk.com 

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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