Skip to content

attributes in dplyr and haven

2 messages · Conklin, Mike (GfK), Hadley Wickham

#
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 -
$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.
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.conklin at gfk.com 
T +1 763 417 4545 | M +1 612 567 8287 
www.gfk.com
#
Install the latest version of dplyr? Should be fixed there.
Hadley

On Tue, Aug 4, 2015 at 9:40 AM, Conklin, Mike (GfK)
<Mike.Conklin at gfk.com> wrote: