Reputation: 2279
I am going over the book Advanced R by Hadley. The book has a question which makes me really confused:
> structure(1:6, comment = "my attribute")
[1] 1 2 3 4 5 6
When you print that object you don't see the comment attribute. Why? Is the attribute missing, or is there something else special about it?
Could anyone help me understand what's going on here?
Upvotes: 7
Views: 842
Reputation: 162401
An attribute named "comment" is treated specially by R's default print
method. From ?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’).
Upvotes: 10