Message-ID: <CABdHhvFqwxkM8_DjUdGiB9ympzPFtj8VoviWDyfKbft7LKEMdA@mail.gmail.com>
Date: 2011-11-04T00:36:07Z
From: Hadley Wickham
Subject: any updates w.r.t. lapply, sapply, apply retaining classes
In-Reply-To: <CAKfbWjv8Zt-JSd=XSHy-HhNSsARp-ZDWH712NuLM3V6dEkQuMA@mail.gmail.com>
> ? ?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/