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.

My Publications

I have written several books on ecology and data analysis

Statistics for Ecologists
Using R and Excel
£34.99
Beginning R: The Statistical
Programming Language
£26.99
The Essential R
Reference
£44.99
Community
Ecology
£39.99
Managing Data
Using Excel
£24.99

Register your interest for our Training Courses

We run training courses in data management, visualisation and analysis using Excel and R: The Statistical Programming Environment. Courses will be held at our training centre in Sutton, South London. Alternatively we can come to you and provide the training at your workplace.




    Get In Touch Now

    for any information regarding our training courses, publications or help with a data project