Hadley,

you've added function labelled to haven, which is great. However, when
it so happens that in SPSS a variable has no long label, your code
considers it to be NULL rather than an NA. NULL is correct, but NA
would probably be better.

For example, I've read in an SPSS file:

library(haven)
spss1 <- read_spss("SPSS_Example.sav")

varnames <- names(spss1)
mylabels <- unlist(lapply(spss1, attr, "label"))

length(varnames)
[1] 64

length(mylabels)
[1] 62


Because in this particular dataset there were 2 variables without
either variable labels or data labels.
When I run lapply(spss1, attr, "label") I see under those 2 variables
"NULL" - which is true and valid.
However,  would it be possible to have instead of NULL an NA? This way
the length of varnames and mylables would the same and one could put
them side by side (e.g., in one data frame)?


Thanks a lot!

-- 
Dimitri Liakhovitski

______________________________________________
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