I have x,y data and would like to compute the average of y at each level
of x.
x
[1] 0.006110 0.007027 0.007027 0.007027 0.008081 0.008081 0.008081 0.008081
[9] 0.008081 0.008081 0.008081 0.009293 0.009293 0.009293 0.009293 0.009293
[17] 0.009293 0.009293 0.009293 0.010686 0.010686 0.010686
Try (untested):
p1 - tapply(y, x, function(z) mean(z == 0))
HTH,
Andy
From: Bill Simpson [mailto:[EMAIL PROTECTED]
I have x,y data and would like to compute the average of y at
each level
of x.
x
[1] 0.006110 0.007027 0.007027 0.007027 0.008081 0.008081
0.008081 0.008081 [9]
one way that works is:
sapply(split(y,x), mean)
Bill
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
On 7 Nov 2003 at 9:47, Bill Simpson wrote:
Since your y is 0-1 the following works:
tapply(x, y ,mean)
aggregate(x, y, mean)
gives the output in a different format.
Kjetil Halvorsen
I have x,y data and would like to compute the average of y at each level
of x.
x
[1] 0.006110 0.007027