Skip to contents

A selector function to use in tidyverse functions

Usage

has_tag(tags)

Arguments

tags

A character vector of tags you want to operate on

Value

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

Examples

## create safeframe
x <- make_safeframe(cars,
  mph = "speed",
  distance = "dist"
)
head(x)
#> 
#> // safeframe object
#>   speed dist
#> 1     4    2
#> 2     4   10
#> 3     7    4
#> 4     7   22
#> 5     8   16
#> 6     9   10
#> 
#> tagged variables:
#>  mph - speed
#>  distance - dist 

if (require(dplyr) && require(magrittr)) {
  x %>%
    select(has_tag(c("mph", "distance"))) %>%
    head()
}
#> 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
#> Loading required package: magrittr
#> 
#> // safeframe object
#>   speed dist
#> 1     4    2
#> 2     4   10
#> 3     7    4
#> 4     7   22
#> 5     8   16
#> 6     9   10
#> 
#> tagged variables:
#>  mph - speed
#>  distance - dist