as_integer: Convert a Factor Data Frame to Integer

Description Usage Arguments Value See Also Examples

Description

Converts a data.frame of factors to integers.

Usage

1
as_integer(x, cols = NULL, fun = as.integer)

Arguments

x

A data.frame of factors.

cols

Numeric indices of the columns to incude (use - to exclude as well). Default is to assign random NAs to all columns except the first column.

fun

An as. coercion function to apply to each column. Default is as.integer.

Value

Returns a data.frame equal to the class of x with integer columns rather than factor.

See Also

r_series

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
as_integer(r_series(likert_7, 5, 10))
as_integer(r_series(likert_7, 5, 10), cols = c(2, 4))

library(dplyr)
r_data_frame(n=100,
    age,
    political,
    sex,
    grade
) %>%
    as_integer(2:3)


Search within the wakefield package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.