[R] Making an S3 object act like a data.frame

hadley wickham h.wickham at gmail.com
Thu Mar 9 14:16:22 CET 2006


> > I'm guessing this is pretty much impossible to get around, because
> > there is no way to tell eval how to deal with myobj type objects, and
> > lm only dispatches based on the type of the first argument.
>
> Did you write an as.data.frame method?  From ?model.frame

My as.data.frame is :

"as.data.frame.ggobiDataset" <- function(x, ...) {
	as.data.frame(.GGobiCall("getData", x))
}

(which in the context of my problem retrieves the data corresponding
to x, an external pointer to a ggobi dataset)

I still get the error reported above.

Hadley

>
>      data: 'data.frame', list, 'environment' or object coercible to
>            'data.frame' containing the variables in 'formula'.  Neither
>            a matrix nor an array will be accepted.
>
> so I believe that an as.data.frame method is all that is required.
>
> --
> 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
>




More information about the R-help mailing list