replacer: Replace Cells in a Matrix or Data Frame

Description Usage Arguments Value Examples

View source: R/replacer.R

Description

Replace elements of a dataframe, matrix or vector with least restrictive class.

Usage

1
replacer(dat, replace = 0, with = "-")

Arguments

dat

Data; either a dataframe, matrix or vector.

replace

Element to replace.

with

Replacement element.

Value

Returns a dataframe, matrix or vector with the element replaced.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
replacer(mtcars[1:10, ], 0, "REP")
replacer(mtcars[1:10, ], 4, NA)
replacer(c("a", "b"), "a", "foo")
#replace missing values (NA)
dat <- data.frame(matrix(sample(c(1:3, NA), 25, TRUE), ncol=5))
replacer(dat, NA, "FOO")

## End(Not run)

trinker/qdap documentation built on Sept. 30, 2020, 6:28 p.m.