S7_class: Retrieve the class specification of an object

View source: R/class.R

S7_classR Documentation

Retrieve the class specification of an object

Description

S7_class() returns a class specification for any R object, in a form that can be passed to method() or used in any S7 dispatch context.

  • For S7 objects, the S7 class.

  • For S3 objects, a new_S3_class() wrapping class(x).

  • For S4 objects, the S4 class.

  • For base types, the matching ⁠class_*⁠ (e.g. class_integer).

  • For missing arguments, returns class_missing.

Usage

S7_class(object)

Arguments

object

Any R object.

Value

A class specification.

Examples

Foo := new_class()
S7_class(Foo())

# Also works on non-S7 objects
S7_class(1L)
S7_class("x")
S7_class(mean)
S7_class(factor("a"))

S7 documentation built on Nov. 19, 2026, 9:06 a.m.