Re: [R] error in using by + median

2008-05-02 Thread Prof Brian Ripley
The help says A data frame is split by row into data frames subsetted by the values of one or more factors, and function 'FUN' is applied to each subset in turn. You attempting to apply median() to a data frame -- it does no work, unlike mean() On Fri, 2 May 2008, vito muggeo

[R] error in using by + median

2008-05-02 Thread vito muggeo
dear all, Could anyone explain me the behaviour of median() within by()? (I am running R.2.7.0) thanks, vito H-cbind(rep(0:1,l=20),matrix(rnorm(20*2),20,2)) by(H[,-1],H[,1],mean) INDICES: 0 V1 V2 -0.2101069 0.2954377