[.linelist | R Documentation |
The []
and [[]]
operators for linelist
objects behaves like for regular
data.frame
or tibble
, but check that tagged variables are not lost, and
takes the appropriate action if this is the case (warning, error, or ignore,
depending on the general option set via lost_tags_action()
) .
## S3 method for class 'linelist'
x[i, j, drop = FALSE]
## S3 replacement method for class 'linelist'
x[i, j] <- value
## S3 replacement method for class 'linelist'
x[[i, j]] <- value
## S3 replacement method for class 'linelist'
x$name <- value
x |
a |
i |
a vector of |
j |
a vector of |
drop |
a |
value |
the replacement to be used for the entries identified in |
name |
a literal character string or a name (possibly backtick
quoted). For extraction, this is normally (see under
‘Environments’) partially matched to the |
If no drop is happening, a linelist
. Otherwise an atomic vector.
lost_tags_action()
to set the behaviour to adopt when tags are
lost through subsetting; default is to issue a warning
get_lost_tags_action()
to check the current the behaviour
if (require(outbreaks) && require(dplyr) && require(magrittr)) {
## create a linelist
x <- measles_hagelloch_1861 %>%
tibble() %>%
make_linelist(
id = "case_ID",
date_onset = "date_of_prodrome",
age = "age",
gender = "gender"
) %>%
mutate(result = if_else(is.na(date_of_death), "survived", "died")) %>%
set_tags(outcome = "result") %>%
rename(identifier = case_ID)
x
## dangerous removal of a tagged column setting it to NULL issues a warning
x[, 1] <- NULL
x
x[[2]] <- NULL
x
x$age <- NULL
x
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.