Description Usage Arguments Value Examples
The function shield
is made to facilitate
the propagation of attributes of an object obj
through R operations.
1 |
obj |
An object. |
at |
A named list, the attributes to be possibly added to
|
propagate |
character. The method to be applied, one of If If If If |
keep_also |
character. A vector of named attributes to be added to the final result. |
The object obj
with possibly different attributes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | library(dplyr)
df <- data.frame(x = sample(10, 5, rep = TRUE),
y = sample(10, 5, rep = TRUE)) %>%
at_mutate(example = "yes",
package = "dplyr",
class = c("my_tbl", "data.frame"))
tribe(df)
# Attributes are lost when the object passes through dplyr verbs
df2 <- df %>%
mutate(z = 3)
tribe(df2)
# Most attributes are kept
df3 <- shield(df2, tribe(df), propagate = "most")
tribe(df3)
# To keep the class, use 'keep_also'
df4 <- shield(df2, tribe(df), propagate = "most", keep_also = "class")
tribe(df4)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.