Variable labels in the R package Haven with SPSS

前端 未结 2 1156
清歌不尽
清歌不尽 2021-01-11 15:14

I\'m trying to access the variable labels (this is the description of the variable) from an SPSS por file with the haven package. I can do it just fine with the foreign pack

相关标签:
2条回答
  • 2021-01-11 15:21

    As stated in read_spss labels are stored as attributes of each column rather than attributes of the data.frame. Try

    lapply(with_haven, function(x) attributes(x)$label)
    
    0 讨论(0)
  • 2021-01-11 15:27

    The function does the trick.

    sapply(with_haven, attr,"label")

    0 讨论(0)
提交回复
热议问题