getR6Class: Get R6 Class Name

Description Usage Arguments Details Value Examples

Description

Gets the name of the given R6 object

Usage

1
getR6Class(object, classname = TRUE, n.par = 0, pos = -1)

Arguments

object

R6 object.

classname

logical, if TRUE (default), returns the name of the class otherwise returns the class.

n.par

numeric, which class should be returned? By default returns the class of the object, increasing the number returns parents of the class (if applicable).

pos

environment to search in, default is -1 (current)

Details

The function works for R6 objects not classes. If the function fails make sure the class is first constructed. This is a wrapper for class(object) when the object may have multiple levels of inheritance, additionally it ensures the correct classname is used in case of a complex naming scheme.

Value

string giving R6 class name.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
parent <- R6::R6Class("parent")
child <- R6::R6Class("child",inherit = parent)
getR6Class(child$new(), n.par = 0)
getR6Class(child$new(), n.par = 1)
getR6Class(parent$new(), FALSE, n.par = 0)

## Not run: 
getR6Class(parent$new(), parent = 1)

## End(Not run)

RaphaelS1/RSmisc documentation built on June 7, 2019, 8:20 p.m.