R中的结构和属性
structure and attribute in R
我正在阅读 Hadley 的 Advanced R 一书。书中有个问题让我很困惑:
> structure(1:6, comment = "my attribute")
[1] 1 2 3 4 5 6
当您打印该对象时,您看不到评论属性。为什么?是缺少属性,还是有其他特殊之处?
谁能帮我理解这是怎么回事?
名为 "comment" 的属性由 R 的默认 print
方法特殊处理。来自 ?comment
:
Description:
These functions set and query a _comment_ attribute for any R
objects. This is typically useful for ‘data.frame’s or model
fits.
Contrary to other ‘attributes’, the ‘comment’ is not printed (by
‘print’ or ‘print.default’).
我正在阅读 Hadley 的 Advanced R 一书。书中有个问题让我很困惑:
> structure(1:6, comment = "my attribute")
[1] 1 2 3 4 5 6
当您打印该对象时,您看不到评论属性。为什么?是缺少属性,还是有其他特殊之处?
谁能帮我理解这是怎么回事?
名为 "comment" 的属性由 R 的默认 print
方法特殊处理。来自 ?comment
:
Description:
These functions set and query a _comment_ attribute for any R
objects. This is typically useful for ‘data.frame’s or model
fits.
Contrary to other ‘attributes’, the ‘comment’ is not printed (by
‘print’ or ‘print.default’).