Learn R Programming

BioGeoBEARS (version 0.2.1)

unlist_df4: Unlist the columns in a data.frame, with more checks, adf, and dfnums_to_numeric

Description

Sometimes, matrices or data.frames will malfunction due to their having lists as columns and other weirdness. This runs unlist and additional checks, and forces conversion to a data.frame at the end. It also adds dfnums_to_numeric which should remove the problem of numbers columns being of class character.

Usage

unlist_df4(df, ...)

Arguments

df
matrix or other object transformable to data.frame
...
Additional options passed to dfnums_to_numeric.

Value

outdf data.frame

Details

See especially data.matrix for a possibly simpler alternative.

See Also

unlist_df, dfnums_to_numeric, cls.df, data.matrix

Examples

Run this code
x = matrix(c(1,2,3,4,5,6), nrow=3, ncol=2)
cls.df(x)
unlist_df4(x)

x = matrix(c(1,2,3,4,5,"A"), nrow=3, ncol=2)
cls.df(x)
unlist_df4(x)

x = adf(matrix(c(1,2,3,4,5,"A"), nrow=3, ncol=2))
names(x) = c("A","B")
cls.df(x)
unlist_df4(x)

Run the code above in your browser using DataLab