8000 GitHub - xoopR/R62S3 at v1.2.1
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

xoopR/R62S3

Repository files navigation

R62S3

Build Status Lifecycle codecov License: MIT CRAN Version CRAN Summary

What is R62S3?

A helper function in R to automatically generate S3 dispatch and methods from an R6ClassGenerator. Useful to allow for a fully R6 object-oriented programming interface alongside familiar S3 dispatch, but without the need to code hundreds of lines for each S3 method.

How to Use R62S3

R62S3 is very simple to use as it consists of one function only! The usage (with defaults) is

R62S3::R62S3(R6Class, dispatchClasses = list(R6Class), assignEnvir = .GlobalEnv)

The parameters allow R62S3 to be a highly flexible method that can:

  • Create S3 methods for any amount of R6 classes
  • Add S3 methods to any R given environment (assuming unlocked)

I recommend it in your zzz.R file for any package that uses R6. This can either be done for specified classes:

.onLoad <- function(libname, pkgname){
  R62S3::R62S3::R62S3(yourR6Class, assignEnvir = parent.env(environment()))
}

Or for every R6 class:

.onLoad <- function(libname, pkgname){
  lapply(ls(name=parent.env(environment())),function(x){
    if(inherits(get(x),"R6ClassGenerator"))
   
7851
   R62S3::R62S3(get(x),assignEnvir = parent.env(parent.env(environment())))
  })
}

Installation

For a stable release, install from CRAN

install.packages("R62S3")

Or install the latest dev build with

devtools::install_github("RaphaelS1/R62S3")

Acknowledgements

Dr Franz Kiraly for initial discussions about the idea.
Prof. Dr. Peter Ruckdeschel for conversations that lead to a simplification in the code structure.

About

Automatic conversion of R6 public methods to S3 and S4 methods and functions.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages

0