as_tibble | R Documentation |
as_tibble()
turns an existing object, such as a data frame or
matrix, into a so-called tibble, a data frame with class tbl_df
. This is
in contrast with tibble()
, which builds a tibble from individual columns.
as_tibble()
is to tibble()
as base::as.data.frame()
is to
base::data.frame()
.
as_tibble()
is an S3 generic, with methods for:
data.frame
: Thin wrapper around the list
method
that implements tibble's treatment of rownames.
matrix
, poly
,
ts
, table
Default: Other inputs are first coerced with base::as.data.frame()
.
as_tibble_row()
converts a vector to a tibble with one row.
If the input is a list, all elements must have size one.
as_tibble_col()
converts a vector to a tibble with one column.
## S3 method for class 'Seurat'
as_tibble(
x,
...,
.name_repair = c("check_unique", "unique", "universal", "minimal"),
rownames = NULL
)
x |
A data frame, list, matrix, or other object that could reasonably be coerced to a tibble. |
... |
Unused, for extensibility. |
.name_repair |
Treatment of problematic column names:
This argument is passed on as |
rownames |
How to treat existing row names of a data frame or matrix:
Read more in rownames. |
'tibble'
The default behavior is to silently remove row names.
New code should explicitly convert row names to a new column using the
rownames
argument.
For existing code that relies on the retention of row names, call
pkgconfig::set_config("tibble::rownames" = NA)
in your script or in your
package's .onLoad()
function.
Using as_tibble()
for vectors is superseded as of version 3.0.0,
prefer the more expressive as_tibble_row()
and
as_tibble_col()
variants for new code.
tibble()
constructs a tibble from individual columns. enframe()
converts a named vector to a tibble with a column of names and column of
values. Name repair is implemented using vctrs::vec_as_names()
.
data(pbmc_small)
pbmc_small |> as_tibble()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.