Hi Md, One way is to form a subset of your data, then calculate the means by year:
# assume your data is named mddat mddat2<-mddat[mddat$month < 7,] jan2jun<-by(mddat2$value,mddat2$year,mean) Jim On Mon, Aug 3, 2020 at 8:52 PM Md. Moyazzem Hossain <hossai...@juniv.edu> wrote: > > Hi, > > I have a dataset having monthly observations (from January to December) > over a period of time like (2000 to 2018). Now, I am trying to take an > average the value from January to July of each year. > > The data looks like > Year Month Value > 2000 1 25 > 2000 2 28 > 2000 3 22 > .... ...... ..... > 2000 12 26 > 2001 1 27 > ....... ........ > 2018 11 30 > 20118 12 29 > > Can someone help me in this regard? > > Many thanks in advance. > > *Regards,* > *Md* > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.