Skip to contents

Coerce object to data.frame

Usage

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

# S4 method for IntegerRanges
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

# S4 method for Matrix
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

x

Object.

row.names, optional

Refer to base::data.frame for usage details.

...

Additional arguments.

Value

data.frame.

Note

Updated 2022-02-08.

Examples

data(
    IntegerRanges,
    sparseMatrix,
    package = "AcidTest"
)

## `IntegerRanges` to `data.frame` ====
from <- IntegerRanges
to <- as.data.frame(from)
head(to)
#>   start end width names score
#> 1     1   5     5     a     1
#> 2    10  14     5     b     2
#> 3    20  24     5     c     3

## `Matrix` to `data.frame` ====
from <- sparseMatrix
to <- as.data.frame(from)
head(to)
#>        sample01 sample02 sample03 sample04 sample05 sample06 sample07 sample08
#> gene01        0        7        0        0        0        0        0        0
#> gene02        0        0        0        0        0        0        0        0
#> gene03        0        0        0        0        0        0        0        0
#> gene04        0        0        0        0        0       21        0        0
#> gene05        0        0        0        0        0        0       28        0
#> gene06        0        0        0        0        0        0        0       35
#>        sample09 sample10
#> gene01        0        0
#> gene02        0        0
#> gene03       14        0
#> gene04        0        0
#> gene05        0        0
#> gene06        0        0