add_class: Add a class to an object

View source: R/add_class.R

add_classR Documentation

Add a class to an object

Description

Adds a class to an object.

Usage

add_class(x, new_class, location = "first")

Arguments

x

the object to add a class to

new_class

the new class or classes

location

should the new class come before the old classes or after them?

Value

the object, but with new classes

Examples

a <- "Hello world!"
class(a)
b <- add_class(a, "awesome_text")
class(b)

# You can also add multiple classes to an object at once!
c <- add_class(a, c("class1", "class2"))
class(c)

chris-s-friedman/Friedman documentation built on Feb. 12, 2023, 8:02 p.m.