This function is designed to ease the changes of column's class of a given data frame.

setColClass(x, colid, cls)

Arguments

x

a data frame or an R object to be coerced into a data frame.

colid

the identity of columns for which class are to be changed.

cls

a character vector containing the classes' names to be used in the same order as colid. By default, cls is repeated until its size equals colid's size.

Value

A data frame whose columns have the desired classes.

Examples

df1 <- matrix(signif(runif(20),4), ncol=2) df2 <- setColClass(df1, 2, 'character') str(df1)
#> num [1:10, 1:2] 0.6433 0.3144 0.2275 0.0635 0.0785 ...
str(df2)
#> 'data.frame': 10 obs. of 2 variables: #> $ V1: num 0.6433 0.3144 0.2275 0.0635 0.0785 ... #> $ V2: chr "0.9258" "0.9202" "0.152" "0.6542" ...