如何获取tibble中列名的描述?
How to get the description of column name in tibble?
在 R 中,我使用 qualtRics
包读取我的 Qualitrics 数据,使用 sjlabelled
设置标签。
如何得到下图中的"What would you.."?
这是 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?"
要获取属性本身,请使用
attr(raw$QA1, "label")
这会给你一个 named character
向量,虽然你可以在任何需要字符串的地方使用它,但如果你更喜欢删除名字(为了控制台美观),那么你也可以使用 unname
函数:
unname(attr(raw$QA1, "label"))
在 R 中,我使用 qualtRics
包读取我的 Qualitrics 数据,使用 sjlabelled
设置标签。
如何得到下图中的"What would you.."?
这是 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?"
要获取属性本身,请使用
attr(raw$QA1, "label")
这会给你一个 named character
向量,虽然你可以在任何需要字符串的地方使用它,但如果你更喜欢删除名字(为了控制台美观),那么你也可以使用 unname
函数:
unname(attr(raw$QA1, "label"))