Questions tagged [r6]

The R6 package provides a type of class which is similar to R’s standard reference classes, but it is more efficient and doesn’t depend on S4 classes and the methods package

181 questions
1
vote
1 answer

use of $ and () in same syntax?

I'm certain there is a really basic answer to this, which is possibly why I'm finding it hard to actually search for and find an answer. But... can somebody please explain exactly what it means to combine $ and () in the same syntax in R? For…
Roasty247
  • 679
  • 5
  • 20
1
vote
1 answer

Access formal arguments of an R6 method

Is there a way to access the arguments of an R6 method? For example, I can access the arguments of rstan::stan() with: library(rstan) formalArgs(rstan::stan) #> [1] "file" "model_name" "model_code" "fit" #> [5]…
Jake Thompson
  • 2,591
  • 1
  • 16
  • 32
1
vote
0 answers

How to integrate database connection to R6 class in R

Hello I would like to assign a dbConnection to a R6 class but it fails. LastProfilZdb <- R6Class( classname = "LastProfilZdb", public = list( name = NULL, zp = NULL, data = NULL , zp_id = function() { …
1
vote
1 answer

Recursive search for a node in nested R6 tree - How to break the loop?

I am trying to implement a search algorithm in R similar to the following, that searches for a node in a tree of nested R6 classes: search = function(node){ if (private$name == node){ self } else { if(all(!is.na(private$list))){ …
1
vote
1 answer

Putting initial values into an R6 Singleton

I would like to store initial values in a Singleton in R, so I am using the R6 Singleton class. The examples show how to manipulate internal variables, but I cannot find a way to pass in values. I tried library( R6 ) library( R6P ) Parameters <-…
Mark Bower
  • 569
  • 2
  • 16
1
vote
1 answer

Shallow and deep copy of R6 elements in a list

Here is a simple R6Class C = R6::R6Class( "C", public = list( x = NULL, initialize = function(x) { self$x=x } ) ) By default the clone method takes deep=FALSE (and I would not know how to…
Remi.b
  • 17,389
  • 28
  • 87
  • 168
1
vote
1 answer

R Shiny - Saving results of dynamically created modules

I encountered the following problem that I have tried to summarize in this minimal reproducible example. The app should be able to dynamically create modules and render the UI of the module - obj_UI in my example - in a tab of the tabsetpanel objTP.…
Thomas
  • 72
  • 6
1
vote
1 answer

R: Vectorise setting active fields in R6

I have a simple R6 object generator, with a get/set active binding: myClass <- R6Class("myClass", private = list( ..status = TRUE ), active = list( …
jayb
  • 555
  • 3
  • 15
1
vote
1 answer

How to return event$data in rstudio/websocket

I am trying to extend websocket::Websocket with a method that sends some data and returns the message, so that I can assign it to an object. My question is pretty much identical to…
Benjamin Schwetz
  • 624
  • 5
  • 17
1
vote
1 answer

R6 pass a self$FUN as parameter

I am starting to built a "user-friendly" R6 class and want to make a function does most of the work of my class. This is my structure so far x <- X$new() veggie_cubes <- veggie %>% x$cubesX(ID) veggie_slices <- veggie %>% x$sliceX(ID) My question…
Domingo
  • 613
  • 1
  • 5
  • 15
1
vote
3 answers

R6 classes, get all fields as named list

I would like to retrieve the values of all my attributes of R6Class objects as a list. Preferably the values would come with the attribute names. Ideally this could be written generally so that it works for inherited classes as well. Unfortunately…
53RT
  • 649
  • 3
  • 20
1
vote
2 answers

Access elements of an R6 class that instantiates another R6 class

Say I have a class SimpleClass and one of the methods of that class can return an object of another class, e.g. SimpleClass <- R6::R6Class( "SimpleClass", public = list( initialize = function() { private$a <- 1 }, cls_two =…
nathaneastwood
  • 3,664
  • 24
  • 41
1
vote
1 answer

Is there any way to remove an R6 object using it's own method?

Taking an example of a basic R6 class given below: library(R6) Demo = R6Class("Demo", public = list( initialize = function(){ message("demo object initialized!") }, delete =…
Akshit
  • 424
  • 4
  • 15
1
vote
1 answer

Use an expression to subset R6Class based on attributes

I have a R6 class BarContainer that contains a vector of Bar, where Bar is another R6 class. I would like to implemented a method subset in BarContainer that would subset the vector of Bar to match with the expression given as argument. Bar =…
Remi.b
  • 17,389
  • 28
  • 87
  • 168
1
vote
1 answer

Parallization of different instances in a R6class

I am asking for help to design a specific R6class and especially to design a run method to would run processes in parallel. Note that all of the code example listed below have not been tested and most likely contain errors. They are just here to…
Remi.b
  • 17,389
  • 28
  • 87
  • 168