Re: [R] Creating and Using Objects in R

2009-07-09 Thread Gabor Grothendieck
Here it is done without S3. Note that UseMethod is basically just an alternative to an if statement. Perhaps this makes it more understandable. x1 <- list(x = 1, y = 2) class(x1) <- "xypoint" x2 <- list(r = 1, theta = pi/2) class(x2) <- "rthetapoint" XPOS <- function(x) { if (inherits(x,

[R] Creating and Using Objects in R

2009-07-09 Thread Lorenzo Isella
Dear All, I am not very into object-oriented programming, but I would like to learn the ropes for some R applications. Quoting from the online R language definition (paragraph 5.1) Consider the following simple example. A point in two-dimensional Euclidean space can be specified by its Cartesi