getAttribute | R Documentation |
Safely get the attribute of an object. An error is given if the attribute does not exist (and do.stop = TRUE)
getAttribute(x, attributeName, do.stop = TRUE)
x |
object from which to take the attribute |
attributeName |
name of the attribute to be returned |
do.stop |
if |
x <- structure(1, a = 2)
# getAttribute(x, "b") # gives a clear error message
identical(getAttribute(x, "a"), attr(x, "a")) # is TRUE
# Get an attribute's attribute by means of a "path" notation
y <- structure(1, a = structure(2, b = 3))
z <- structure(4, y = y)
str(y)
str(z)
kwb.utils::getAttribute(y, "a/b")
kwb.utils::getAttribute(z, "y/a/b")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.