monthly {timeSeries} | R Documentation |
Special monthly series
Description
Functions and methods dealing with special monthly
"timeSeries"
objects.
Usage
countMonthlyRecords(x)
rollMonthlyWindows(x, period = "12m", by = "1m")
rollMonthlySeries(x, period = "12m", by = "1m", FUN, ...)
Arguments
x |
a |
period , by |
character strings specifying the rollling period composed by the
length of the period and its unit. Examples: |
FUN |
the function for the statistic to be applied. For example,
|
... |
arguments passed to the function |
Details
countMonthlyRecords
computes a "timeSeries"
that holds
the number of monthly counts of the records.
rollMonthlyWindows
computes start and end dates for rolling
time windows.
rollMonthlySeries
computes the statistics defined by the
function FUN
over a rolling window, internally computed by
the function rollMonthlyWindows
. Note, the periods may be
overlapping, may be dense, or even may have gaps.
Value
for countMonthlyRecords
and rollMonthlySeries
, a
"timeSeries"
object.
for rollMonthlyWindows
, a list with attribute
"control"
keeping the start
and end
dates of the
series. The components of the list are:
from |
an object from class |
to |
an object from class |
Examples
## Load Microsoft Daily Data Set:
x <- MSFT
## Count Monthly Records -
counts <- countMonthlyRecords(x)
counts
## Quaterly Non-Overlapping Time Periods -
windows <- rollMonthlyWindows(counts[-1, ], period = "3m", by = "3m")
windows
## Nicely Reprint Results as a data.frame -
data.frame(cbind(FROM=format(windows$from), TO=format(windows$to)))
## Compute the average number of monthly trading days per quarter -
rollMonthlySeries(counts[-1, ], period = "3m", by = "3m", FUN=mean)