Solved – a good use of the ‘comment’ function in R

I just discovered the comment function in R. Example:

x <- matrix(1:12, 3,4) comment(x) <- c("This is my very important data from experiment #0234",                 "Jun 5, 1998") x comment(x) 

This is the first time I came by this function and was wondering what are common/useful uses of it.
Since it is quite difficult to search "R comment" in google and find relevant results, I was hoping someone here might share with his experience.

To second @Gavin, Frank Harrell has developed efficient ways to handle annotated data.frame in R in his Hmisc package. For example, the label() and units() functions allow to add dedicated attributes to R objects. I find them very handy when producing summary of data.frame (e.g., with describe()).

Another useful way of using such an extra attribute is to apply a timestamp on a data set. I also add an attribute for things like random seed, fold number (when I use k-kold or LOO cross-validation).

Similar Posts:

Rate this post

Leave a Comment