[R] force apply() to return a list
Robin Hankin
r.hankin at noc.soton.ac.uk
Mon Nov 21 14:59:53 CET 2005
Hi Gabor
thanks for this.
On 21 Nov 2005, at 13:26, Gabor Grothendieck wrote:
> Try this:
>
> tapply(a, row(a), f, simplify = FALSE)
>
[
here
a <- cbind(1:5 , 5:1)
f <- function(x){list(1:max(x[1],4))}
]
This also works. I actually need unlist(... , recursive=FALSE)
to pass the list to do.call() but that 's fine.
But, my question here is: how does one arrive at
such a solution from the manpage? The manpage seems
to indicate that the first argument to tapply() is a ragged
array, or a vector.
I can't reconcile Gabor's use of tapply() with the manpage.
How to understand Gabor's suggestion better?
>>
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743
More information about the R-help
mailing list