unfactor: Convert a factor to a character (or number)

Description Usage Arguments Value Author(s) See Also Examples

View source: R/unfactor.R

Description

Analogous to the function factor, unfactor will convert a factor to a character or integer

Usage

1

Arguments

x

The vector of factors you wish to replace

levels

A numeric vector of the values that will replace the factors

labels

A character vector of the values to be replaced

numeric

Should the labels be returned (i.e., characters)? Or the numbers?

Value

A numeric or character vector

Author(s)

Dustin Fife

See Also

factor

Examples

1
2
3
	#### create sample of male/female participants (at random)
x = as.factor(sample(c("Male", "Female"), 12, replace=TRUE))
unfactor(x, levels=c(0,1), labels=c("Male", "Female"))

Example output

Loading required package: MASS
 [1] 0 0 0 0 1 0 0 0 0 0 0 1

fifer documentation built on May 30, 2017, 7:40 a.m.

Related to unfactor in fifer...