Description Usage Arguments Value Examples
select a named element from a list or data.frame with default for missed values
1 | get_attribute(x, attribute, default = NULL)
|
x |
a list-like object (e.g. data.frame) |
attribute |
the name or index of an element in x |
default |
value to return if attribute is missed or error (NULL) |
the value of attribute from x or default
1 2 3 4 5 6 7 8 9 | ## Not run:
y <- list('a' = 1)
x <- data.frame('b' = 2)
get_attribute(y, 'a', 2) # 1
get_attribute(y, 'b', 1) # 1
get_attribute(x, 'a', 2) # 2
get_attribute(x, 'b', 1) # 2
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.