【发布时间】:2018-01-05 21:12:32
【问题描述】:
有人能解释一下为什么 typeof (data.frame) 在 R 中显示 list 吗?相反,class 给出了预期的类型。例如,演示使用内置的 data.frame mtcars。
> typeof(mtcars)
[1] "list"
> class(mtcars)
[1] "data.frame"
关于如何使用 typeof 与 class 的任何提示?
【问题讨论】:
标签: r attributes
有人能解释一下为什么 typeof (data.frame) 在 R 中显示 list 吗?相反,class 给出了预期的类型。例如,演示使用内置的 data.frame mtcars。
> typeof(mtcars)
[1] "list"
> class(mtcars)
[1] "data.frame"
关于如何使用 typeof 与 class 的任何提示?
【问题讨论】:
标签: r attributes
data.frame 和 data.table 都是项目(向量,如果你愿意的话)的集合(列表),每个项目的长度相同(即每一列都是列表中的一个项目,无论如何在 R 内部)。这就是为什么与矩阵不同,列可以有不同的类。
干杯。
【讨论】: