CollapsABEL (version 0.10.11)

correctTypes_methods: Convert columns of a data frame to certain types

Description

Convert columns of a data frame to certain types

Usage

correctTypes(dat, col_names = NULL, types)

Arguments

dat
data.frame The data frame whose types you want to change.
col_names
character. Names of columns, the types of which you want to change.
types
character. Names of new types. Should be the same length as col_names

Value

data.frame. With specified classes.

Examples

Run this code
## Not run: 
# dat = randNormDat(3, 3)
# dat[, 2] = as.character(dat$V2)
# dat1 = correctTypes(dat, types = rep("numeric", 3))
# all(colClasses(dat1) == rep("numeric", 3))
# dat2 = correctTypes(dat, 2, "numeric")
# all(colClasses(dat2) == rep("numeric", 3))
# ## End(Not run)

Run the code above in your browser using DataLab