我正在阅读Hadley的Advanced R一书。这本书有一个问题,这让我真的很困惑:
> structure(1:6, comment = "my attribute")
[1] 1 2 3 4 5 6
当您打印该对象时,看不到注释属性。为什么?该属性丢失了吗,还是还有其他特殊之处?
有人可以帮助我了解这里发生的事情吗?
print
方法对名为“ comment”的属性进行了特殊处理。从?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’).