Description Usage Arguments Details Value Note Author(s) References See Also Examples
Replaces a single value in a set of columns with another given value. This makes it easy to change the default missing value indicator, for example.
1 | replace.value( data, names, from=NA, to=as.integer(0), verbose = FALSE)
|
data |
data frame |
names |
a vector of character strings identifying columns to be updated |
from |
value to find and replace, can specify vectors |
to |
replacement value, must be a scalar |
verbose |
prints warnings if typeof(from) != typeof(to) |
Will replace storage mode of 'to' with mode of 'from' in dataset.
A data frame, with the same number of observations as the input
data
, but with replaced values as specified.
Related materials and worked examples are available at http://wand.stanford.edu/anchors/
Jonathan Wand http://wand.stanford.edu
Wand, Jonathan; Gary King; and Olivia Lau. (2007) “Anchors: Software for Anchoring Vignettes”. Journal of Statistical Software. Forthcoming. copy at http://wand.stanford.edu/research/anchors-jss.pdf
Wand, Jonathan and Gary King. (2007) Anchoring Vignetttes in R: A (different kind of) Vignette copy at http://wand.stanford.edu/anchors/doc/anchors.pdf
1 2 3 4 5 6 7 8 9 10 | ## data with zeroes as missing values in responses
data(poleff)
## data with NA missing values in responses
data(poleffna)
## convert NA to 0:
dd <- replace.value(poleffna,c("xsayself","xsay1","xsay2","xsay3","xsay4","xsay5"))
## convert 0 to NA:
dd2 <- replace.value(poleff,c("xsayself","xsay1","xsay2","xsay3","xsay4","xsay5"),0,as.double(NA))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.