Skip to contents

Coerce object to data.frame

Usage

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

# S4 method for IRanges
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 2023-10-06.

Examples

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

## `IRanges` to `data.frame` ====
from <- IRanges
to <- as.data.frame(from)
head(to)
#>   start end width score
#> 1     1   5     5     1
#> 2    10  14     5     2
#> 3    20  24     5     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