note {mark} | R Documentation |
Append a note to an object
Description
An alternative to the base::comment()
.
Usage
note(x) <- value
set_note(x, value)
note(x)
Arguments
x |
An object |
value |
The note to attach; if |
Details
When the note is assigned to an object a new class will be added,
note
, so that a print
function can call an S3 method. The print for
this can be adjusted for it's width by using the option mark.note.width
which defaults to the option width
when not set.
The type of object assigned to the note is not restricted, so user beware of odd prints or additional features added to the notes fun.
When assigning a note (with note<-
, and its alias set_note()
) the
noted
class is added to the object. This allows the print.noted
class
to be dispatched and for the note to be printed every time the object is
called/printed and the next print method used. However, it will not be
called when not interactive()
Value
-
note<-
,set_note()
will returnx
(with the"note"
attribute assigned) -
note()
will retrieve the"note"
attribute
Examples
x <- c("x", "k", "c", "d")
comment(x) <- "This is just a comment"
comment(x)
# Comment is intentionally hidden
x
note(x) <- "Just some random letters"
note(x)
# Note is now present every time
x
# Assigning `NULL` will remove note (and class)
note(x) <- NULL
note(x) # NULL
x # No more note