change_in_dt: Change matching entries in data.table

Description Usage Arguments

View source: R/change_in_dt.R

Description

Search a data.table for a pattern 'from' and replace it with 'to'.

Usage

1
2
change_in_dt(dat, columns = NA, from, to, stop_missing = TRUE,
  change_in_dat = FALSE)

Arguments

dat

Data.table or data.frame.

columns

Columns of data.table/data.frame to search and replace values in. Defaults to NA, which equals all columns.

from

Single string that represents pattern to be replaced. Also accepts regular expressions.

to

Single string that 'from' is changed into.

stop_missing

Logical. Whether to stop when one of your numerical column entries is not found in 'dat'. Defaults to TRUE to avoid errors. In case of FALSE, the function will change all values in the columns that were found

change_in_dat

Logical. Whether to change 'dat' directly, without returning it. Defaults to FALSE and thus returns a data.table with the desired changes without changing the input 'dat' directly.


cfbeuchel/CarlHelpR documentation built on Dec. 24, 2019, 8:08 p.m.