在R中,我使用qualtRics
包读取我的Qualitrics数据,并使用sjlabelled
设置标签。
如何在下图中显示“您会怎样?”?
以下是print
的输出:
> print(raw$QA1)
[1] "Red and black" "Red and black" "Red and black" "Red and black"
[5] "Red and black" "Red and black" NA NA
[9] NA
attr(,"label")
QA1
"What's the color of the robot?"
编辑:我尝试了attr
函数:
> print(attr(raw$QA1, "label"))
QA1
"What's the color of the robot?"
答案 0 :(得分:1)
要获取属性本身,请使用
attr(raw$QA1, "label")
这将为您提供一个名为 character
的向量,并且您可以在需要字符串的任何内容中使用该向量,但是如果您希望删除该名称(出于控制台美观的考虑) ,那么您也可以使用unname
函数:
unname(attr(raw$QA1, "label"))