Add a class in first place

Share:

Description

Add a new class name to the classes of an R object, and make it the first in the list of classes the objects belongs to.

Usage

1
  firstclass(x) <- value

Arguments

x

the object the new class is assigned to. Needs to be an object that can be copied.

value

character string with the new class name.

Value

The same object x, now belonging (additionally) to the class given as "value".

Author(s)

Ute Hahn, ute@imf.au.dk

Examples

1
2
3
4
5
x <- data.frame(u = 1:2, t = 3:4)
class(x)
firstclass(x) <- "my.first.class"
class(x)
firstclass(x) <- "data.frame"