使用Haven_labelled_spss-设置NA值后数据失去“标签”

时间:2019-05-21 09:22:14

标签: r

我有一个labelled_spss数据集,通过 haven::read_sav("path/file.sav", user_na = TRUE)。以某种方式,在使用labelled::na_values之后,我在属性中松了label标签,但我不知道为什么。

一个例子:

#Before
attributes(a$q24)
  

$ label   [1]“如果明天要举行全民投票,您将如何投票?”

     

$ format.spss    [1]“ F3.0”

     

$ class    [1]“ haven_labelled”

     

$ labels    国家应该在联盟国家应该离开不会投票                                    1 2 966            不知道                                  977

# Setting NA
na_values(a$q24) <- 977
attributes(a$q24)
  

$ format.spss    [1]“ F3.0”

     

$ class    [1]“ haven_labelled”

     

$ labels    国家应该在联盟国家应该离开不会投票                                    1 2 966            不知道                                  977

     

$ na_values   [1] 977

有人可以帮我吗?

1 个答案:

答案 0 :(得分:1)

这是labelled中的错误。应该在开发版本中修复。