Description Usage Arguments Value Note Examples
Coerce to DataFrame
.
1 2 3 4 | as.DataFrame(x, ...)
## S4 method for signature 'list'
as.DataFrame(x, row.names = NULL)
|
x |
Object. |
... |
Additional arguments. |
row.names |
|
DataFrame
.
Don't define as
coercion method for list
here. It will create
issues with data.frame
coercion. Use as.DataFrame
instead to coerce
a list
to DataFrame
.
Updated 2020-01-08.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | data(data.table, sparseMatrix, tbl_df, package = "acidtest")
## Matrix to DataFrame ====
from <- sparseMatrix
to <- as(from, "DataFrame")
to
## data.table to DataFrame ====
from <- data.table
to <- as(from, "DataFrame")
head(to)
## tbl_df to DataFrame ====
from <- tbl_df
to <- as(from, "DataFrame")
head(to)
## list to DataFrame ====
## Use `as.DataFrame()` instead of `as()` for `list` class.
from <- list(
a = list(c(1, 2), c(3, 4)),
b = list(NULL, NULL)
)
to <- as.DataFrame(from)
to
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.