Structure and attribute in R

I am going through the book Advanced R by Hadley. There is a question in the book that confuses me a lot:

> structure(1:6, comment = "my attribute") [1] 1 2 3 4 5 6 

When you print this object, you do not see the comment attribute. What for? Is there an attribute missing or is there something else special?

Can someone help me understand what is going on here?

+5
source share
1 answer

An attribute named "comment" is specially processed by the default method R print . 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'). 
+8
source

Source: https://habr.com/ru/post/1211745/


All Articles