Skip to contents

A selector function to use in tidyverse functions

Usage

has_tag(tags)

Arguments

tags

A character vector of tags listing the variables you want to operate on

Value

A numeric vector containing the position of the columns with the requested tags

Examples

if (require(outbreaks) && require(dplyr)) {

  ## dataset we'll create a linelist from
  measles_hagelloch_1861

  ## create linelist
  x <- make_linelist(measles_hagelloch_1861,
    id = "case_ID",
    date_onset = "date_of_prodrome",
    age = "age",
    gender = "gender"
  )
  head(x)

  x %>%
    select(has_tag(c("id", "age"))) %>%
    head()
}
#> Loading required package: outbreaks
#> Loading required package: dplyr
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
#> Warning: The following tags have lost their variable:
#>  date_onset:date_of_prodrome, gender:gender
#> 
#> // linelist object
#>   case_ID age
#> 1       1   7
#> 2       2   6
#> 3       3   4
#> 4       4  13
#> 5       5   8
#> 6       6  12
#> 
#> // tags: id:case_ID, age:age