as_basetable: Coerce an object to a basetable

View source: R/basetable-class.R

as_basetableR Documentation

Coerce an object to a basetable

Description

as_basetable() turns a data frame, a list of equal-length columns, a matrix, or anything else as.data.frame() accepts into a basetable: an ordinary data frame carrying basetable's lightweight class, the same object every basetable verb returns. Use it when a package or script wants to hand its own data to basetable explicitly, rather than relying on a verb to stamp the class.

Usage

as_basetable(x, ...)

## S3 method for class 'basetable'
as_basetable(x, ...)

## S3 method for class 'data.frame'
as_basetable(x, ...)

## Default S3 method:
as_basetable(x, ...)

Arguments

x

An object to coerce.

...

Passed to as.data.frame() by the default method; ignored otherwise.

Details

The data are left unchanged; only the class and the row.names attribute are normalised. An object that is already a basetable is returned as-is, and as.data.frame() strips the class again.

Value

A basetable: a data frame with the basetable class.

See Also

is_basetable()

Examples

bt <- as_basetable(data.frame(g = c("a", "b"), x = 1:2))
class(bt)
identical(as_basetable(bt), bt)
as_basetable(list(g = c("a", "b"), x = 1:2))

basetable documentation built on Sept. 18, 2026, 9:13 a.m.