replacer | R Documentation |
Replace elements of a dataframe, matrix or vector with least restrictive class.
replacer(dat, replace = 0, with = "-")
dat |
Data; either a dataframe, matrix or vector. |
replace |
Element to replace. |
with |
Replacement element. |
Returns a dataframe, matrix or vector with the element replaced.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.