R:了解 dput() 输出

R: Understanding dput() output

感谢 SO 用户,我最近学会了命令 dput()。现在的问题是我不理解输出。我想了解变量 edu.deg.level 的数据。我可以看到列表格式中有 10 个值,但我不明白 1L、0L 是什么意思或它们被分配给了什么。这是代码:

> dput(head(df1,10))
 structure(list(edu.degree.level = c(1L, 0L, 1L, 1L, 0L, 1L, 1L, 
 1L, 1L, 0L), immig.view = structure(c(7, 4, 5, 1, 7, 5, 7, 1, 3, 1), 
 label = "J1 Do you think immigration is good or bad for Britain's economy?", 
 labels = c(`Not stated` = -999, 
`Don`t know` = -1, `1 Bad for economy` = 1, `2` = 2, `3` = 3, 
`4` = 4, `5` = 5, `6` = 6, `7 Good for economy` = 7), class = "haven_labelled")), 
 row.names = c(NA, 10L), class = "data.frame")

非常感谢!

在 R 中有两种主要类型 "numeric" 原子向量。第一种是 "integers",或计数,将它们想象成您将用于计数等的数字。- 2, -1, 0, 1, 2, 3... 另一种是 "double" 类型或实数,它可以是无限长数轴上任何位置的数字,例如-8.43, -2.10, 0.001, 18.2797615.

在数字后面加上 L 只是告诉 R 它们是整数而不是实数。在你的 dput 中,只是该列充满了 1 和 0,而且这些都是整数。