replace.value: Replaces occurences of a value with another value in set of...

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

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.

Usage

1
replace.value( data, names, from=NA, to=as.integer(0), verbose = FALSE) 

Arguments

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)

Details

Will replace storage mode of 'to' with mode of 'from' in dataset.

Value

A data frame, with the same number of observations as the input data, but with replaced values as specified.

Note

Related materials and worked examples are available at http://wand.stanford.edu/anchors/

Author(s)

Jonathan Wand http://wand.stanford.edu

References

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

See Also

anchors

Examples

 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))

anchors documentation built on May 2, 2019, 6:59 a.m.