match_cols: Match column name.

Description Usage Arguments Details Value Examples

View source: R/df.R

Description

match_cols returns matching column names from a table. The matching is performed using regular expressions and grepl.

Usage

1
match_cols(tbl, patt, ...)

Arguments

tbl

A tibble or dataframe.

patt

Regular expression pattern to pass to grepl.

...

Parameters to pass along to grepl.

Details

Ignores case by default. Can be overridden by passing ignore.case via ....

Value

A character vector of column names matching the regex.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## dataframe to convert
key <- c(1000L, 2000L, 3000L, 4000L, 1000L)
amount <- c("46.41", "118.11", "84.68", "493.59", "51.10")

test_df <- data.frame(key, amount)

# column names
my_col <- "^am"

# use
test_df %>%
  match_cols(my_col)

curtisalexander/CRAmisc documentation built on May 12, 2017, 2:22 p.m.