asbasetable: Coerce an object to a basetable

View source: R/basetable-class.R

asbasetableR Documentation

Coerce an object to a basetable

Description

asbasetable() 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

asbasetable(x, ...)

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

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

## Default S3 method:
asbasetable(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 plain basetable is returned as-is. A subclass of basetable (an object carrying extra classes in front of "basetable") is returned as a plain basetable, as as.data.frame() returns a plain data frame, and as.data.frame() strips the class again.

Value

A basetable: a data frame with the basetable class.

See Also

isbasetable()

Examples

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

basetable documentation built on Nov. 14, 2026, 1:08 a.m.