convert: Convert factor or character variables into integers

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

Description

Use convert to transform factor or character variables into ordered integer values prior to using anchors or chopit.

Usage

1
convert(vars, data, order, ...)

Arguments

vars

a character vector identifying the variables in data to be converted to integers.

data

data frame containing vars.

order

a character vector identifying the factor levels to be converted to integers, in increasing order. If NA is omitted here (default), NA values are retained as NA. If NA is included, then NA values are converted to the the last category (which can be adjusted via ....

...

addtional arguments passed to factor.

Value

A data frame, with the character or factor variables identified in vars replaced by integers.

Author(s)

Olivia Lau

References

Jonathan Wand, 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

See Also

anchors, chopit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
set.seed(391)
a <- sample(c("net gain", "little effect",  "modest loss", "major loss"),
            20, replace=TRUE)

dta <- as.data.frame( list(ncost=a) , stringsAsFactors  = FALSE)
print(dta)

newdat <- convert("ncost", data = dta, 
                  order = c("net gain", "little effect",  "modest loss", "major loss"))

print(newdat)

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