[R] Query about calculating the monthly average of daily data columns

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Thu Sep 12 17:16:05 CEST 2019

No reproducible example, so hard to say. What class is your "date" column?
-- factor, character, Date?  See ?Date
Once you have an object of appropriate class -- see ?format.Date -- ?months
can extract the month and ?ave can do your averaging. No explicit looping
is needed.

The tidydata alternative universe can also do all these things if that's
where you prefer to live.

As usual, any attached data was stripped. See ?dput for one way to include
data in your post.


On Thu, Sep 12, 2019 at 7:54 AM Subhamitra Patra <subhamitra.patra using gmail.com>

> Dear R-users,
> I have daily data from 03-01-1994 to 29-12-2000. In my datafile, he first
> column is date and the second and third columns are the returns of the
> country A, and B. Here, the date column is same for both countries. I want
> to calculate the monthly average of both country's returns by using a loop,
> and then, I want to export the results into excel.
> Please help me in this regard.
> Please find the attached datasheet.
> Thank you.
> --
> *Best Regards,*
> *Subhamitra Patra*
> *Phd. Research Scholar*
> *Department of Humanities and Social Sciences*
> *Indian Institute of Technology, Kharagpur*
> [image: Mailtrack]
> <
> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&
> >
> Sender
> notified by
> Mailtrack
> <
> https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&
> >
> 09/12/19,
> 08:23:07 PM
> ______________________________________________
> R-help using 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.

	[[alternative HTML version deleted]]

More information about the R-help mailing list