[R] Derived classes

rkevinburton at charter.net rkevinburton at charter.net
Fri Sep 5 05:56:27 CEST 2008


Coming from a C++ and C# background I would like to know how inheritance works with 'R'. The classical example is I can define an abstract class 'Shape' and have an array of 'Shape's but each instance could be a Circle, Square, Triangle, etc. because they all derive from 'Shape'. At runtime if I wish I can tell the type of the 'Shape' using various language specific operators. In 'R' it seems that each 'function' in general returns an object that is specific to that function. For example 'stl' returns an 'stl' object, 'lm' retuirns an 'lm' object, 'kmeans' returns a 'kmens' object etc. If I have an array of these objects what can I use to tell the type of object in 'R' and runtime? Any examples would be helpful.

Thank you.

Kevin



More information about the R-help mailing list