GithubHelp home page GithubHelp logo

xoopr / r62s3 Goto Github PK

View Code? Open in Web Editor NEW
31.0 2.0 0.0 442 KB

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

Home Page: https://xoopR.github.io/R62S3/

License: Other

R 100.00%
r object-oriented-programming oop dispatch

r62s3's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

r62s3's Issues

No applicable method for 'function'

Hi, I'm trying to use this package, but I can't seem to make it work.

To reproduce what I'm seeing, create a new R project with a MyClass.R file with the following:

#' R6 Class representing somethin
#'
#' A class representing a model.
MyClass <- R6::R6Class(
  classname = "MyClass",
  public = list(
    #' @field a something
    a = 1,

    #' @description
    #' prints
    hello_world = function() {
      cat("Hello!")
    },

    #' @description
    #' summarizes
    summary = function() {
      cat("Summary!", self$a)
    }
  )
)


#' Creates a new model
#'
#' @return a new model
#' @export
#'
#' @examples
#' a <- my_class()
my_class <- function() {
  MyClass$new()
}

Also create a zzz.R file:

# Exports public methods as S3 methods.
R62S3::R62S3(R6Class = MyClass, assignEnvir = topenv())

Then, try to run the following tests:

Restarting R session...

> devtools::load_all()
ℹ Loading testpackage
> a <- MyClass$new()
> a$hello_world()
Hello!
> hello_world.MyClass(a)
Hello!
> hello_world(a)
Error in UseMethod("hello_world", object) : 
  no applicable method for 'hello_world' applied to an object of class "c('MyClass', 'R6')"
> summary(a)
Error in object[[i]] : wrong arguments for subsetting an environment

So, it seems the generic is created, but it doesn't work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.