Displaying 1 result from an estimated 1 matches for "grpscale".
Did you mean:
grayscale
2002 Jun 05
1
[Re: Re: Scaling on a data.frame]
...er preserving - it seems unsave.
>
> Something like that would be nice:
> "by(d[1], FAC1) <- by(d[1], FAC1, scale)"
Hey,
finely this works (adapted from Prof. Ripleys suggestion):
grpmeans <- tapply(d$VALUE, d$FAC1, mean, na.rm=T)
d$c <- d$VALUE - grpmeans[d$FAC1]
grpscale <- tapply(d$c, d$FAC1, sd, na.rm=T)
d$cs <- d$c / grpscale[d$FAC1]
It was funny to get 3 eligible answers
but non of them worked at first go.
1) grpmeans <- tapply(d[1], FAC1, mean)
d$s <- scale(d[1], grpmeans[d$FAC1], FALSE)
2) zz <- by(d1,d1$FAC1,function(x,...){c(scale(x$VAL...