easyswap: Swap all instances in a data.table

Description Usage Arguments Value

View source: R/easyswap.R

Description

easyswap is a function that efficiently finds and replaces all instances of a given value with another given value. This occurs across all columns to use, unless an optional argument specifying the columns is provided.

Usage

1
2
easyswap(dt = NULL, find = NA, swap = NULL, cols = NULL,
  force = FALSE, copy = FALSE)

Arguments

dt

A data.table to search and swap values in

find

A value to find across all or a subset of columns. Default is NA.

swap

A value to replace 'find' with

cols

An optional character vector giving the names of the columns to make the swap in. If not provided, swap will happen across all columns. See examples below.

force

A boolean value specifying whether to try and coerce column classes in the event where the swap value is a different data type than the column. See examples below.

copy

A boolean value indicating whether to make the swap on a COPY of the data. Default is false and the swap is made in memory. See examples below.

Value

A modified copy of dt


bfatemi/easydata documentation built on Oct. 7, 2019, 4:35 p.m.