df_search: Search and highlight occurences of a pattern

View source: R/tools.R

df_searchR Documentation

Search and highlight occurences of a pattern

Description

Search and highlight occurences of a pattern in a data frame

Usage

df_search(x, pattern = NULL, cols = NULL)

Arguments

x

a data frame

pattern

a pattern; if NULL, the search results will be removed

cols

which columns to search for (if NULL, all columns will be searched)

Details

df_search is for highlighting cells matching a specific pattern.

Value

a color data frame object with the search pattern set for the given columns (or reset, if the pattern was NULL)

Examples

options(colorDF_tibble_style=TRUE)
if(require(dplyr)) {

  # Search for "blue" in any column
  starwars %>% df_search("blue")

  # Search in a specific column
  starwars %>% df_search("(Human|Wookie)", "species")

  # save the search pattern in a new object
  saved <- starwars %>% df_search("blue")

  # remove the search patterns
  saved <- df_search(saved)
}

colorDF documentation built on Sept. 26, 2022, 5:06 p.m.