as.data.frame(x, row.names = NULL, optional = FALSE, ...)
"as.data.frame"(x, ..., stringsAsFactors = default.stringsAsFactors())
"as.data.frame"(x, row.names = NULL, optional = FALSE, ..., stringsAsFactors = default.stringsAsFactors())
is.data.frame(x)
NULL
or a character vector giving the row
names for the data frame. Missing values are not allowed.TRUE
, setting row names and
converting column names (to syntactic names: see
make.names
) is optional.as.data.frame
returns a data frame, normally with all row names
""
if optional = TRUE
.is.data.frame
returns TRUE
if its argument is a data
frame (that is, has "data.frame"
amongst its classes)
and FALSE
otherwise.
as.data.frame
is a generic function with many methods, and
users and packages can supply further methods. For classes that act
as vectors, often a copy of as.data.frame.vector
will work
as the method. If a list is supplied, each element is converted to a column in the
data frame. Similarly, each column of a matrix is converted separately.
This can be overridden if the object has a class which has
a method for as.data.frame
: two examples are
matrices of class "model.matrix"
(which are
included as a single column) and list objects of class
"POSIXlt"
which are coerced to class
"POSIXct"
.
Arrays can be converted to data frames. One-dimensional arrays are treated like vectors and two-dimensional arrays like matrices. Arrays with more than two dimensions are converted to matrices by flattening all dimensions after the first and creating suitable column labels.
Character variables are converted to factor columns unless protected
by I
.
If a data frame is supplied, all classes preceding "data.frame"
are stripped, and the row names are changed if that argument is supplied.
If row.names = NULL
, row names are constructed from the names
or dimnames of x
, otherwise are the integer sequence
starting at one. Few of the methods check for duplicated row names.
Names are removed from vector columns unless I
.
data.frame
, as.data.frame.table
for the
table
method (which has additional arguments if called directly).