R中的结构和属性

hi1*_*i15 6 attributes structure r

我正在阅读哈德利的"高级R"一书.这本书有一个让我感到困惑的问题:

> structure(1:6, comment = "my attribute")
[1] 1 2 3 4 5 6
Run Code Online (Sandbox Code Playgroud)

打印该对象时,您看不到comment属性.为什么?该属性是否缺失,还是有其他特殊之处?

谁能帮我理解这里发生了什么?

Jos*_*ien 9

名为"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’).
Run Code Online (Sandbox Code Playgroud)