classed
classed <- function (x, cls)
{
class(x) <- cls
x
}
If it doesn't use copy-on-write then the result will be additional slowdown when all your data is copied again and again (I guess it depends on how big the object is).
I've often wondered about this. Any comments from someone who really knows the internals of R? When I first implemented it I did some testing and didn't notice any really big slowdown and I do use a lot of fairly big (multi MB size) objects. But notice that the difference is really in the function call, not in the copying of objects. A function using classed would end classed(x, "whatever") } rather than class(x) <- "whatever" x} I think the copy is (or is not) made in both cases. Paul Gilbert -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._