replace_values_in_dt: Replace values in a data table

View source: R/replace_values_in_dt.R

replace_values_in_dtR Documentation

Replace values in a data table

Description

Replace values in a data.table

Usage

replace_values_in_dt(
  data = NULL,
  old_values = NULL,
  new_values = NULL,
  silent = FALSE
)

Arguments

data

a data object (a data frame or a data.table)

old_values

a vector of old values that need to be replaced

new_values

a new value or a vector of new values that will replace the old values

silent

If silent = FALSE, a message will be printed regarding how many values were replaced. If silent = TRUE, no message will be printed regarding how many values were replaced. (default = FALSE)

Examples

replace_values_in_dt(data = mtcars, old_values = 21.0, new_values = 888)
replace_values_in_dt(data = mtcars, old_values = c(0, 1), new_values = 999)
replace_values_in_dt(
data = mtcars, old_values = c(0, 1), new_values = 990:991)
replace_values_in_dt(
data = data.table::data.table(a = NA_character_, b = NA_character_),
old_values = NA, new_values = "")

kim documentation built on Oct. 9, 2023, 5:08 p.m.