sch {easyr}R Documentation

Search a Data Frame.

Description

Searches all columns for a term and returns all rows with at least one match. Author: Bryce Chamberlain.

Usage

sch(
  x,
  pattern,
  ignore.case = FALSE,
  fixed = FALSE,
  pluscols = NULL,
  exact = FALSE,
  trim = TRUE,
  spln = NULL
)

Arguments

x

Data to search.

pattern

Regex patter to search. Most normal search terms will work fine, too.

ignore.case

Ignore case in search (uses grepl).

fixed

Passed to grepl to match string as-is instead of using regex. See ?grepl.

pluscols

choose columns to return in addition to those where matches are found. Can be a name, number or 'all' to bring back all columns.

exact

Find exact matches intead of pattern matching.

trim

Use trimws to trim columns before exact matching.

spln

Sample data use easyr::spl() before searching. This will speed up searching in large datasets when you only need to identify columns, not all data that matches. See ?spl n argument for more info.

Value

Matching rows.

Examples

sch( iris, 'seto' )
sch( iris, 'seto', pluscols='all' )
sch( iris, 'seto', pluscols='Sepal.Width' )
sch( iris, 'seto', exact = TRUE ) # message no matches and return NULL

[Package easyr version 0.5-8 Index]