[R] assigning the class of an object

peter dalgaard pdalgd at gmail.com
Wed Sep 11 12:02:31 CEST 2013


On Sep 10, 2013, at 23:49 , Rolf Turner wrote:
>> 
> Hmmm.  I did:
> 
> x <- 42
> save(x,file="Robject.RData")
> rm(list=ls())
> obj_name <- load("Robject.RData")
> class(get(obj_name)) <- "myClass"
> x
> 
> and got:
> 
> [1] 42
> attr(,"class")
> [1] "myClass"
> 
> (also got the familiar error message).
> 
> When I did it your way --- without the saving and loading bit --- I got
> the same result that you did.  I.e. assigning the class that way did *not*
> work (as one would expect it wouldn't!).
> 
> This is weird, n'est-ce pas?
> 

A bug, I'm pretty sure.

-p

-- 
Peter Dalgaard, Professor
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list