setcolclass.df: Function to set the class of columns in a data.frame

Description Usage Arguments Value Author(s) Examples

Description

This function enables to set the class of each culumn in a data.frame

Usage

1
setcolclass.df(df, colclass, factor.levels)

Arguments

df

data.frame for which columns' class need to be updated

colclass

class for each column of the data.frame

factor.levels

list of levels for each factor

Value

A data.frame with columns' class and levels properly set

Author(s)

Benjamin Haibe-Kains

Examples

1
2
3
4
tt <- data.frame(matrix(NA, nrow=3, ncol=3, dimnames=list(1:3, paste("column", 1:3, sep="."))), 
stringsAsFactors=FALSE)
tt <- setcolclass.df(df=tt, colclass=c("numeric", "factor", "character"), 
factor.levels=list(NULL, c("F1", "F2", "F3"), NULL))

genefu documentation built on Nov. 1, 2018, 2:25 a.m.