Learn R Programming

mvbutils (version 2.2.0)

as.data.frame.I: Coerce to data.frame, preserving mode of columns

Description

as.data.frame.I(x) protects all columns in x, except factors and numerics, using I() before calling as.data.frame(x).

Usage

as.data.frame.I( x, row.names=NULL, optional=FALSE, ...)

Arguments

x
a list
row.names
NULL or a character vector giving the row names for the data frame. Missing values are not allowed.
optional
logical. If TRUE, setting row names and converting column names (to syntactic names) is optional.
...
passed to as.data.frame after protecting columns.

Value

  • A data.frame with the same columns as x.

See Also

data.frame, I

Examples

Run this code
class( as.data.frame( list( x=letters[1:3]))$x) # factor
mode( as.data.frame( list( x=letters[1:3]))$x) # numeric
class( as.data.frame.I( list( x=letters[1:3]))$x) # AsIs
mode( as.data.frame.I( list( x=letters[1:3]))$x) # character

Run the code above in your browser using DataLab