[R] vector average

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Apr 15 11:02:47 CEST 2002


Bill Simpson <W.Simpson at gcal.ac.uk> writes:

> I have some x,y data like this:
> 
> > Age
>  [1]  9  9  9  9  9  9  9 10 10 10 10 10 10 10 10 10 10 13 13 13 13 13 14
> 14 14
> [26] 14 14 20 20 24 24 24 24 25 25 26 26 26 26 26 26 27 27 27 27 28 28 28
> 31 31
> [51] 33 33 33 33 42 42
> > Eff
>  [1] 0.0020974230 0.0027592200 0.0005083383 0.0032771380 0.0103963000
>  [6] 0.0001853803 0.0003308799 0.0013806050 0.0011010700 0.0004344708
> [11] 0.0004218284 0.0005980084 0.0010793970 0.0028892260 0.0052878420
> [16] 0.0018294950 0.0053974560 0.0090520070 0.0080538370 0.0016778090
> [21] 0.0028991400 0.0087036000 0.0025774670 0.0007077176 0.0114549000
> [26] 0.0075118350 0.0039684140 0.0052012410 0.0014330880 0.0029195920
> [31] 0.0035333520 0.0014361830 0.0137326300 0.0016086470 0.0003588453
> [36] 0.0066563540 0.0006436416 0.0084010880 0.0072078140 0.0069549490
> [41] 0.0047324600 0.0175518600 0.0028563290 0.0111100700 0.0029967400
> [46] 0.0015195310 0.0060652090 0.0024862060 0.0126991500 0.0064851260
> [51] 0.0104344000 0.0011785500 0.0016925290 0.0002736497 0.0144059200
> [56] 0.0064315460
> 
> I would like a plot (unique(Age),E) where E is the average Eff at each
> age. For example, the first point would be:
> (9, 0.002793526)
> 
> Please tell me how to compute E.  Thanks!

tapply(Eff, Age, mean)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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