search for: getarea

Displaying 2 results from an estimated 2 matches for "getarea".

2002 Jan 06
1
How to get setGeneric() to work?
Dear all, I can't see how setGeneric() works. I know perfectly well how to define library(methods); setClass("Square", representation(side="numeric")); # Will become the default method. getArea <- function(object) { stop(paste("Method getArea() is not defined for this class:", data.class(object))); } setMethod("getArea", "Square", function(object) object at side^2); # TEST sq <- Square(8); area <- getArea(sq); However, when use setGe...
2008 Sep 05
1
Derived classes
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