convertType: Convert Types of Variables

Description Usage Arguments Details Value Examples

Description

convertType will convert specified variables in dataset to other types.

Usage

1
convertType(df, toType, vars = -1)

Arguments

df

A dataframe to be converted.

toType

The type converted to be, values must be one of c("fac","cha","int"). If toType="int", the converted result is intercepting the integer part of specified variable, not rounding.

vars

Vector of column names or numbers to convert, -1 means to convert all matched variables based on toType automatically, see details.

Details

when vars=-1, which variables to be converted depends on toType: if toType="fac", all the character variables will be converted; if toType="cha", all the factor variables will be converted; if toType="int", all the numeric variables will be converted.

Value

A new dataframe with the same order of variables

Examples

1
2
data(CreditData)
sample_fac <- convertType(CreditData, toType="fac")

xxzcool/scoremodel documentation built on May 4, 2019, 10:56 a.m.