changeClass: Change classes of multiple variables/columns in a data frame...

Description Usage Arguments Value See Also Examples

Description

Changing classes of many variables in the data frame simultaneously. The function also checks if one is converting a factor to numeric variable and it will make a correct conversion without loss of digits.

Usage

1

Arguments

df

A data frame.

new

A character vector which specifies desired class of each variable in df.

Value

The data frame df where each column has a class as specified in new.

See Also

as.numeric, as.character, as.factor which this function wraps

Examples

1
2
3
4
5
# check the classes of variables in mtcars dataset
sapply(mtcars, class)

# change them to something else
changeClass(mtcars, c("fac", rep("char",10)))

hstojic/hfunk documentation built on May 17, 2019, 6:16 p.m.