Learn R Programming

tidytable (version 0.5.1)

starts_with.: Select helpers

Description

Please note these functions are leftover from before tidytable used tidyselect. You can/should use the normal tidyselect helpers.

These functions allow you to select variables based on their names.

  • any_of.(): Select using a character vector

  • contains.(): Contains a literal string or regex match

  • everything.(): Matches all variables

  • starts_with.(): Starts with a prefix

  • ends_with.(): Ends with a suffix

Usage

starts_with.(match, ignore.case = TRUE, vars = peek_vars(fn = "starts_with"))

dt_starts_with(match, ignore.case = TRUE, vars = peek_vars(fn = "starts_with"))

contains.(match, ignore.case = TRUE, vars = peek_vars(fn = "contains"))

dt_contains(match, ignore.case = TRUE, vars = peek_vars(fn = "contains"))

ends_with.(match, ignore.case = TRUE, vars = peek_vars(fn = "ends_with"))

dt_ends_with(match, ignore.case = TRUE, vars = peek_vars(fn = "ends_with"))

everything.(vars = peek_vars(fn = "everything"))

dt_everything(vars = peek_vars(fn = "everything"))

any_of.(x, ..., vars = peek_vars(fn = "any_of"))

dt_any_of(x, ..., vars = peek_vars(fn = "any_of"))

Arguments

match

A character vector. If length > 1, the union of the matches is taken.

ignore.case

If TRUE, the default, ignores case when matching names.

vars

A character vector of variable names. When called from inside selecting functions like select.() these are automatically set to the names of the table.

x

An index vector of names or locations.

...

These dots are for future extensions and must be empty.

Examples

Run this code
# NOT RUN {
test_df <- tidytable(
  x = 1,
  y = 2,
  double_x = 2,
  double_y = 4)

test_df %>%
  select.(starts_with("x"))

test_df %>%
  select.(ends_with("y"))
# }

Run the code above in your browser using DataLab