[R] How to inherit a base data type (e.g. list, vector)

Bert Gunter bgunter.4567 at gmail.com
Sat Nov 14 18:48:35 CET 2015


??

R has 2 built-in OO "class" systems: S3 and S4. S3, which is less an
OO system than a way of customizing methods (see e.g. methods(plot) or
methods(print)), is simpler. S4 is a more full-fledged OO system,
although those coming from languages like C++ and Java might find it
somewhat idiosyncratic. You need to read up on these -- many web
tutorials discuss them, Hadley Wickham's "Advanced R" book is a good
resource also -- and then decide which, if either, suits your needs.
If you still need help **after** you have done your homework, then
post here.


Cheers,
Bert

Bert Gunter

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
   -- Clifford Stoll


On Fri, Nov 13, 2015 at 7:43 PM, Dawei Cheng <waterfrogcdw at gmail.com> wrote:
> Hi, there
> I'm trying to extend customized type (for example mylist) from a base type
> "list" in R, which contains all functions and prototype of R base "list".
> It should support below operators as "list":
>
> a <- list(column1=c(1:5), column2=c(6:10))
> aa <- mylist(column1=c(1:5), column2=c(6:10))
> a$column1
> 1 2 3 4 5
> aa$column1
> 1 2 3 4 5
>
> All other usages of "list" is expected to be supported my "mylist"
>
> My questions is :
> How could I create the "mylist" in R.
> Thanks for help.
>
> --
>
> *Best RegardsDawei*
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list