[R] scaling-centering a vector using an index

J.R. Lockwood lockwood at rand.org
Thu Sep 5 20:31:42 CEST 2002


> x<-rnorm(10,3)
> f1<-rep(c("a","b"),5)
> f2<-rep(c("c","d"),c(5,5))
> unsplit(lapply(split(x,list(f1,f2)),scale),list(f1,f2)) ##first call
> group<-paste(f1,f2)
> unsplit(lapply(split(x,group),scale),group) ##second call

In your first call, the object

lapply(split(x,list(f1,f2)),scale)

is a list that knows nothing about "f1" and "f2"

thus you can't unsplit that list with respect to those factors.

J.R. Lockwood
412-683-2300 x4941
lockwood at rand.org
http://www.rand.org/methodology/stat/members/lockwood/

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list