If you make a factor with year with levels including all the years that you
want then use tapply eg with dat as the name of the data.frame
The same applies for Month but I have not done so
dat$Yr <- factor(dat$Year, levels = c(1971:1980))
with(dat, tapply(Rain, list(Yr, Month), sum, na.rm=T))
On Tue, 7 Oct 2014 07:25:49 PM Hafizuddin Arshad wrote:
> Dear R users,
>
> I have this kind of data set which is part of my data:
>
> ...
>
> I would like to find the rainfall total for each month within a year. The
> result should be like in this form:
>
> ...
>
> where V1 until V12 as month
2 matches
Mail list logo