An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20120628/c68da30d/attachment.pl>
financial data on flat matrix
2 messages · Ben quant, Jeff Ryan
2 days later
You can look into ?endpoints in xts, but you haven't exactly provided a _reproducible_ example as requested in the posting guidelines. Not personally sure what "flat matrix" is for instance. Also likely why no one has responded thus far. If you make it _easy_ to answer (simple examples which we can try and run), people tend to answer. Jeff
On Thu, Jun 28, 2012 at 11:42 AM, Ben quant <ccquant at gmail.com> wrote:
Hello,
I'm using the Rbbg package (please suggest an alternative that is faster if
you know of one). I'd like to get my data into a flat matrix where row
names are found like this for quarterly data:
get_dates <- function(Start, End,end_of,every)
{
Vec <- as.Date(levels(cut(seq.Date(Start, End, by = end_of),breaks =
every)))
Vec[-1] - 1
}
qtrs = get_dates(from_date, to_date,end_of= "month",every = "quarter")
qtrs = qtrs[length(qtrs):1]
qtrs
[1] "2012-03-31" "2011-12-31" "2011-09-30" "2011-06-30" "2011-03-31"
"2010-12-31" "2010-09-30" "2010-06-30" "2010-03-31" "2009-12-31"
[11] "2009-09-30" "2009-06-30" "2009-03-31" "2008-12-31" "2008-09-30"
"2008-06-30" "2008-03-31" "2007-12-31" "2007-09-30" "2007-06-30"
...and all companies that report after the quarter end date (above) and
before the next one are moved back one. For example, if a company reporting
period ended in Jan. 2012, those values would be on the 2011-12-31 row.
(These are then adjusted for look-ahead using the actual report date.)
Is there a function that will do this in zoo or another package?
Thanks!
Ben
[[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
Jeffrey Ryan jeffrey.ryan at lemnica.com www.lemnica.com www.esotericR.com