coerce-tbl_df: Coerce to tibble

Description Usage Arguments Details Value S3 as_tibble() S4 as() Note See Also Examples

Description

Coerce to tbl_df.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## S3 method for class 'DataFrame'
as_tibble(
  x,
  ...,
  rownames = pkgconfig::get_config("tibble::rownames", "rowname")
)

## S3 method for class 'IPosRanges'
as_tibble(
  x,
  ...,
  rownames = pkgconfig::get_config("tibble::rownames", "rowname")
)

## S3 method for class 'GenomicRanges'
as_tibble(
  x,
  ...,
  rownames = pkgconfig::get_config("tibble::rownames", "rowname")
)

Arguments

x

A data frame, list, matrix, or other object that could reasonably be coerced to a tibble.

...

Other arguments passed on to individual methods.

rownames

How to treat existing row names of a data frame or matrix:

  • NULL: remove row names. This is the default.

  • NA: keep row names.

  • A string: the name of a new column. Existing rownames are transferred into this column and the row.names attribute is deleted. Read more in rownames.

Details

Our defined methods attempt to improve on the defaults in the tibble package to ensure that row names are not dropped by default, which is a poor default for bioinformatics. This is accomplished by setting rownames = "rowname" by default instead of rownames = NULL.

Value

tbl_df.

S3 as_tibble()

transformer extends as_tibble() method support for these S4 classes:

S4 as()

Since tbl_df is a virtual class that extends tbl and data.frame, we need to define an S4 coercion method that allows us to use as() to coerce an object to a tibble.

See getClass("tbl_df") for details on how tibble is a virtual class.

Note

Updated 2020-01-08.

See Also

tibble::as_tibble().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data(DataFrame, GRanges, IRanges, package = "acidtest")

## DataFrame to tbl_df ====
x <- as(DataFrame, "tbl_df")
x <- as_tibble(DataFrame)
print(x)

## GenomicRanges to tbl_df ====
x <- as(GRanges, "tbl_df")
x <- as_tibble(GRanges)
print(x)

## IRanges to tbl_df ====
x <- as(IRanges, "tbl_df")
x <- as_tibble(IRanges)
print(x)

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