addClass {SomaDataIO}R Documentation

Add a Class to an Object

Description

Utility to add (prepend) a class(es) to existing objects.

Usage

addClass(x, class)

Arguments

x

The object to receive new class(es).

class

Character. The name of additional class(es).

Value

An object with new classes.

Author(s)

Stu Field

See Also

class(), typeof(), structure()

Examples

class(iris)

addClass(iris, "new") |> class()

addClass(iris, c("A", "B")) |> class()    # 2 classes

addClass(iris, c("A", "data.frame")) |> class()    # no duplicates

addClass(iris, c("data.frame", "A")) |> class()    # re-orders if exists

[Package SomaDataIO version 6.1.0 Index]