Try this:

rowsum(x0, y0)[,1]/table(y0)

On Mon, May 3, 2010 at 2:11 PM, song song <rprojecthelp@gmail.com> wrote:

> x0=rnorm(100)
> y0=rpois(100,3)+1
>
> ind=as.data.frame(table(y0))
>
> ind1=ind[,1]
> ind2=ind[,2]
>
> phi=NULL
> for (i in 1:length(ind2)){
>   phi[i]=sum(x0[y0==ind1[i]])/ind2[i]
> }
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]

