getObjectClassKind: Get R object class kind

View source: R/getObjectClassKind.R

getObjectClassKindR Documentation

Get R object class kind

Description

Get the class kind of an R object as a string.

Usage

getObjectClassKind(object_o_1)

Arguments

object_o_1

the object to analyze. See is.object.

Value

A single character value, taken in set "S3", "S4", "RC", "R6", "environment", "unknown".

When provided object_ is not an R object, then value NA_character_ is returned.

Author(s)

Fabien Gelineau <neonira@gmail.com>

Maintainer: Fabien Gelineau <neonira@gmail.com>

Examples

##---- typical case ----
getObjectClassKind(new.env())
# [1] NA

myrc <- setRefClass("RC",
  fields = list(x = "numeric"),
  methods = list(
    initialize = function(x = 1) .self$x <- x,
    getx = function() x,
    inc = function(n = 1) x <<- x + n
  )
)

getObjectClassKind(myrc$new())
# [1] RC

myr6 <- R6::R6Class("R6",
  public = list(
    x = NULL,
    initialize = function(x = 1) self$x <- x,
    getx = function() self$x,
    inc = function(n = 1) self$x <- x + n
  )
)

getObjectClassKind(myr6$new())
# [1] R6


wyz.code.offensiveProgramming documentation built on Sept. 25, 2023, 9:05 a.m.