Hi, R-experts I defined a new class of object, called "alpha", which is basically a data.frame. And (I think) I know how to create a method for "alpha", such as "summary.alpha", "plot.alpha". The problem is, when I try to access "alpha" object by usual data.frame method, it won't. For example, suppose X is an object of class "alpha". Then, the commands such as dim(X), X[1,1], none of these works. I want to know how to define a class so that when there is appropriate methods use it, but when there's not use the predetermined method for underlying object. Any comments would be appreciated. Thanks- -- View this message in context: http://www.nabble.com/class-and-method-tf3568696.html#a9969691 Sent from the R help mailing list archive at Nabble.com.
On Thu, 12 Apr 2007, jiho.han wrote:> > Hi, R-experts > > I defined a new class of object, called "alpha", which is basically a > data.frame. And (I think) I know how to create a method for "alpha", such as > "summary.alpha", "plot.alpha". The problem is, when I try to access "alpha" > object by usual data.frame method, it won't. > > For example, suppose X is an object of class "alpha". Then, the commands > such as dim(X), X[1,1], none of these works. > > I want to know how to define a class so that when there is appropriate > methods use it, but when there's not use the predetermined method for > underlying object. Any comments would be appreciated. Thanks-class(X) <- c("alpha", "data.frame") is I think what you want. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Seemingly Similar Threads
- Plotting a cloud/fog of variable density in rgl
- Dynamic hash table size (with static has load)
- rbind-ing list
- How to convert S4 class slots into data.frame or how to assign variables of type 'Date'
- best way to make 5-10 simultaneous calls to the same did at a set time of day