【发布时间】:2019-01-20 07:04:23
【问题描述】:
我在 R 中遇到的所有元素中的 class() 的长度都是 1。
一些例子
library(dplyr)
"string" %>% class %>% length
# [1] 1
123 %>% class %>% length
# [1] 1
0.234 %>% class %>% length
# [1] 1
Sys.Date() %>% class %>% length
# [1] 1
但Sys.time() 的class()(它本身,如上面的示例,长度为1)的长度为2
Sys.time() %>% class %>% length
# [1] 2
为什么?
【问题讨论】:
-
尽管是一个不同的类,
data.table有 2 个类,这里的答案可能有助于解释原因:stackoverflow.com/a/15986236/2449656 -
另外,请参阅此处的 13.6:adv-r.hadley.nz/s3.html
标签: r