An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20111103/7107337a/attachment.pl>
any updates w.r.t. lapply, sapply, apply retaining classes
3 messages · Mike Williamson, Richard M. Heiberger, Hadley Wickham
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20111103/87e661be/attachment.pl>
? ?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/