在R中调用attributes((函数后,我得到以下结果
$dim
[1] 10 1
$index
[1] 1532869958 1532870058 1532870158 1532870258 1532870358 1532870458
[7] 1532870558 1532870658 1532870758 1532870858
attr(,"tzone")
TZ
"Asia/Hong_Kong"
attr(,"tclass")
[1] "POSIXct" "POSIXt"
$class
[1] "xts" "zoo"
$.indexCLASS
[1] "POSIXct" "POSIXt"
$tclass
[1] "POSIXct" "POSIXt"
$和attr((有什么区别?似乎例如attr(,"tzone"(返回下面的相同属性。为什么重复?
$
是从列表中访问元素的一种方式,属性不是列表元素。
字符$
也用于打印列表以显示元素名称。
attributes
的输出是一个列表,这就是为什么你会看到这些$
str(attributes(iris))
# List of 3
# $ names : chr [1:5] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" ...
# $ class : chr "data.frame"
# $ row.names: int [1:150] 1 2 3 4 5 6 7 8 9 10 ...