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
Questions tagged [r6]
181 questions
1
vote
0 answers
Working with large matrix field in R6 object is slow
I'm creating a matrix, representing a certain value for a combination of customers (rows) and features (cols). Let's call this matrix NBA. Based on data received through an API, this matrix needs to be updated many times each second, inserting new…

Johannes Waage
- 11
- 1
1
vote
0 answers
Implementing method dispatch for a R6 class vector
Is there any guidance on how to implement method dispatch for a vector of R6 objects into a dataframe or list?
This works beautiful for single R6-classes
Proper way to implement S3 dispatch on R6 classes
Implementing S3 method dispatch as suggest in…

anselfinger
- 31
- 3
1
vote
0 answers
RSI (using TTR) results differs between proprietary system and bank
Question:
How come there is difference in calculated RSI, between my system and bank, even if using the same settings ? The source data (OHLC) is the same for both systems. I have intentionally left out "maType" since the default is…

Toolbox
- 2,333
- 12
- 26
1
vote
1 answer
Use selectInput() choice to select data in a R6 Class
I am trying to understand how I can use R6 Class Objects in a Shiny app and I wanted to render data in a R6 Object using a selectInput() choice. The select input choices contains the names of my R6 Objects.
I have the following…

Bruno Guarita
- 767
- 10
- 21
1
vote
2 answers
How to handle unknown methods/generics in R
Many languages have special ways to handle unknown methods (examples). The one I'm most familiar with is Python's __getattr__. If someone calls a method you haven't defined for the class, __getattr__ acts as a catch-all and does something.
I've been…

Kyle Ward
- 889
- 1
- 8
- 18
1
vote
0 answers
Method overriding in R6 OO programming
I am using the R6 package for OO programming in a package I am developing. My R6 object stores a data frame as well as other information. I would like to override the data.frame() function when called on my R6 object so that its stored data frame is…
user11035327
1
vote
1 answer
How to access public members in private method in R6Class?
library(R6)
Person<-R6Class("Person",
public=list(
name=NULL,
age=NULL,
initialize=function(name,age){
self$name<-name
self$age<-age
},
GrowUP1=function(){
self$publicGrow()
},
…

beginner
- 13
- 6
1
vote
0 answers
Roxygen - R6 methods
I'm trying to generate some reasonable documentation for R6 classes. Here's an example:
##' GroveR class object
##' @importFrom R6 R6Class
##' @export
GroveR <- R6Class(
portable = FALSE,
private = list(
fileRoot = ".",
artDefs =…

Ken Williams
- 22,756
- 10
- 85
- 147
1
vote
0 answers
R6: add function to main class
I like the set function in R6 as it allows me to build the object more dynamically. I want to be able to start with a blank settings object in the R6Class()$private$settings, and then dynamically add to it when I have new objects and tests.
set…

Jonny Phelps
- 2,687
- 1
- 11
- 20
1
vote
1 answer
forcing modify in place in an R6 class (in R)
So I'm writing a program in R using R6 (my bosses preference). It's got to do some heavy duty number crunching so I'm trying to get the key variables in the R6 classes to modify in place. Unfortunately what works for getting variables to modify in…

Peter Clark
- 161
- 1
- 5
1
vote
1 answer
R - R6 - higher order function - scope of enclosing function
I try to create dynamically the initialize function of R6 class.
First I create unlocked class definition:
cls <- R6::R6Class(
name,
inherit=TPayload,
lock_objects=FALSE,
public=list(
…

Marek Jagielski
- 802
- 10
- 17
1
vote
1 answer
Possible to define indexing methods for R6/reference classes?
I have an R6 class that is basically a wrapper around a matrix-like object. I'd like to define a method for my class that lets me index and subset elements of the matrix directly.
At the moment, my code looks something like this:
cls <-…

Hong Ooi
- 56,353
- 13
- 134
- 187
1
vote
1 answer
Difference between self and private method call in R6
Lately I found myself coding some stuff in R6, and while having fun handling some objects an interesting question came out. When creating a private method (e.g. foo, of the bar) and calling it inside other public methods it works if I either call it…

Erdi
- 88
- 8
1
vote
1 answer
How to find the name of an instantiation of an object in a R6 class?
ann <- Person$new("Ann", "black")
In the example above (which is from this Introduction), how would I get "ann"?
For instance, I would need a method ann$getName that would return "ann".

ariel
- 11
- 5
1
vote
1 answer
Creating private values from other private values in R6
Is there any way to use a private value in order to create another private value inside R6Class()? I am getting errors.
obj <- R6Class(
"abc",
private = list(
a = 2,
b = 2*private$a
)
)
Error in all_named(private) : object 'private'…

SavedByJESUS
- 3,262
- 4
- 32
- 47