coerce-DataFrame: Coerce to data frame

Description Usage Arguments Value Note Examples

Description

Coerce to DataFrame.

Usage

1
2
3
4
as.DataFrame(x, ...)

## S4 method for signature 'list'
as.DataFrame(x, row.names = NULL)

Arguments

x

Object.

...

Additional arguments.

row.names

NULL or character.

Value

DataFrame.

Note

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.

Examples

 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

steinbaugh/transformer documentation built on Jan. 9, 2020, 12:53 p.m.