View source: R/R04-Data_wrangling.R
camr_add_attribute | R Documentation |
Function to add an attribute to an R object while preserving any existing attributes (especially useful for not overwriting attributes for dates to function properly).
camr_add_attribute(x, attribute, label)
x |
An R object. |
attribute |
The element to add as an attribute. |
label |
The label to use in the list of attributes. |
The R object with updated attributes.
Kevin Potter
x <- 1:3
x <- x |> camr_add_attribute( "Hello world", "example" )
print( x )
# Preserves existing attributes
x <- as.Date( c( "2000-01-01", "2010-06-15", "2020-12-25" ) )
x <- x |> camr_add_attribute( "Hello world", "example" )
print( class( x ) )
print( attributes( x )$example )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.