[Rd] [R] any updates w.r.t. lapply, sapply, apply retaining classes
Hadley Wickham
hadley at rice.edu
Fri Nov 4 01:36:07 CET 2011
> I agree that it is non-trivial to solve the cases you & I have posed.
> However, I would wholeheartedly support having an error spit back for any
> function that does not explicitly support a class. In this case, if I
> attempt to do sapply(x, class), and 'x' is of class "difftime", then I
> should receive an error "sapply cannot function upon class 'difftime' ".
> Why do I take this stance? There are at least 2 strong reasons:
I don't see why that command should be a problem because class()
returns a string.
A better example might be sapply(x, identity) which in general you
would hope to be identical to x:
x <- structure(1:10, class = "blah")
identical(x, sapply(x, identity))
# [1] FALSE
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
More information about the R-devel
mailing list