[R] time-series aggregation of information
smartpink111 at yahoo.com
Fri May 17 21:48:35 CEST 2013
May be this helps:
ddply(dat,.(Date), summarize, wtdmeans=weighted.mean(Parameter,Weight))
# Date wtdmeans
#1 2012-01-31 70.00000
#2 2012-02-29 82.96482
#3 2012-03-31 77.10183
----- Original Message -----
From: Chirag Maru <chirag.maru at ironfinancial.com>
To: "r-help at R-project.org" <r-help at r-project.org>
Sent: Friday, May 17, 2013 2:48 PM
Subject: [R] time-series aggregation of information
I have following data for which I need to calculate the weighted aggregate value of the parameter at each time.
So for the above sample the solution looks like:
Could I potentially use tapply / aggregate for this? Would like to avoid a for loop if possible.
The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer.
Any information contained herein is neither an offer to sell nor a solicitation to buy any interest in any investment fund. An offer can only be made by the approved offering memorandum, which contains important information concerning risk factors and other material information and must be read carefully before any decision to invest is made. Securities and derivatives trading are speculative and involve a risk of substantial loss. Past results are not necessarily indicative of future performance.
All incoming and outgoing e-mails are archived and may be reviewed and/or produced at the request of regulators or in connection with civil litigation. IRON Holdings, LLC. accepts no liability for any errors or omissions arising as a result of transmission.
[[alternative HTML version deleted]]
R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help