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 <- Person$new(1,'a',4)
Person2 <- Person$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]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to