[R] my ugly apply/sweep code needs help
Tyler Smith
tyler.smith at mail.mcgill.ca
Sun May 20 16:45:32 CEST 2007
On 2007-05-19, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
>
> sweep.median2 <- function(data.mat, group.vec, group.sel) {
> sweep.med <- function(x) sweep(x, 2, apply(x, 2, median))
> f <- function(g) cbind(g+0, sweep.med(data.mat[group.vec == g,,drop
>= FALSE ]))
> do.call(rbind, lapply(group.sel, f))
> }
>
Thanks for this -- very helpful!
Tyler
More information about the R-help
mailing list