Re: [R] basic problem but can't solve it

From: Christophe Pallier <christophe_at_pallier.org>
Date: Tue, 22 May 2007 19:21:39 +0200

tapply(Measure,Month,mean)[as.character(Month)]

-- 
Christophe Pallier (http://www.pallier.org)


On 5/22/07, Benoit Chemineau <benoitchemineau_at_gmail.com> wrote:

>
> Hello,
> I have a basic problem but i can't figure it out with the
> table underneath. I would like to compute monthly averages.
> I would like to have the average measure for month #5 for the first
> three rows (the same number in the first three lines) and the average
> measure for month #6 for the last four rows ((the same number in the first
> three lines) in a separate vesctor (let's call it 'result')
> I tried to use a "while" statement inside a "for" loop but it doesn't
> seem to work.
> Can someone please help me with this ?
>
> Measure Month
> 2.28 5
> 14.04 5
> 0.60 5
> 0.21 6
> 0.96 6
> 0.75 6
> 1.28 6
>
> Thank you !
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch 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.
>
[[alternative HTML version deleted]] ______________________________________________ R-help_at_stat.math.ethz.ch 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.
Received on Tue 22 May 2007 - 19:10:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 May 2007 - 19:31:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.