This function works similarly to dplyr::select()
but can in addition refer
to tagged variables through the tags
argument. When variables are selected
using both procedures, tagged variables are output as the last columns.
Usage
# S3 method for linelist
select(.data, ..., tags = NULL)
Arguments
- .data
a
linelist
object- ...
the variables to select, using
dplyr
compatible syntax- tags
a
character
indicating tagged variables to select using tag names (seetags_names()
) for default values; values can be named, in which case the output columns will be renamed accordingly (e.g.onset = "date_onset"
will output a column named 'onset').
See also
select_tags()
to select tags onlytags_df()
to return adata.frame
of all tagged variables
Author
Thibaut Jombart thibaut@data.org
Examples
if (require(outbreaks) && require(dplyr) && require(magrittr)) {
## dataset to create a linelist from
head(measles_hagelloch_1861)
## create linelist
x <- measles_hagelloch_1861 %>%
tibble() %>%
make_linelist(id = "case_ID",
date_onset = "date_of_prodrome",
age = "age",
gender = "gender")
x
## change select all dates and some tags
x %>%
select(contains("date"), tags = c("id", "age", "gender"))
## showing warnings when tags are lost
x %>%
select(1:3)
## getting rid of warnings on the fly
x %>%
lost_tags_action("none") %>%
select(1:3)
## reset default behaviour
lost_tags_action()
}
#> Warning: The following tags have lost their variable:
#> gender:gender, age:age
#> Lost tags will now issue a warning.