[R] R6 object that is a list of referenced object
    Cristina Pascual 
    crosspide at hotmail.com
       
    Wed Nov 15 19:52:10 CET 2017
    
    
  
Dear community,
I am having a class, let's say Person,
Person <-  R6Class("Person",
                     public = list(
                       idPerson = NULL,
                       name = NULL,
                       age = NULL,
                       initialize = function(idPerson = NA, name = NA, age = NA) {
                        self$idPerson <- idPerson
                        self$name <- name
                        self$age <- age
                       }
                     ) # public
) # Person
I have created:
Person1 <- Particle$new(1,'a',4)
Person2 <- Particle$new(2,'b',5)
and I also have a class Community:
Community <- R6Class("Community",
                 public = list(
                   e = NULL,
                   initialize = function() self$e <- Person$new()
                 )
)
I want to create
Community1 = List<Person>
and add Person1 and Person2 to Community1 (Community1 <- Community1$add(Person1)
                                                                                    Community1 <- Community1$add(Person2)
????)
How can I write this with R6? I cannot find the proper example in the website.
Can anybody help me?
Thanks in advance,
	[[alternative HTML version deleted]]
    
    
More information about the R-help
mailing list