Add comments to objects in R

All R objects have attributes – one of these can be a comment. You can set or view the comment attribute of an object using the comment() command. For example:

x <- c(2, 3, 5, 4, 3, 6)
comment(x)
NULL
comment(x) <- "A simple numeric variable"
comment(x)
[1] "A simple numeric variable"

Use the comment to remind you what the object is – it is easy to forget later.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s