The result will contain the open and close for the given period, as well as the maximum and minimum over the new period, reflected in the new high and low, respectively.
If volume for a period was available, the new volume will also be calculated.
to.minutes(x,k,name,...)
to.minutes3(x,name,...)
to.minutes5(x,name,...)
to.minutes10(x,name,...)
to.minutes15(x,name,...)
to.minutes30(x,name,...)
to.hourly(x,name,...)
to.daily(x,drop.time=TRUE,name,...)to.weekly(x,drop.time=TRUE,name,...)
to.monthly(x,indexAt='yearmon',drop.time=FALSE,name,...)
to.quarterly(x,indexAt='yearqtr',drop.time=FALSE,name,...)
to.yearly(x,drop.time=TRUE,name,...)
to.period(x, period = 'months', k = 1, indexAt, name=NULL, ...)
to.monthly
and to.quarterly
,
which index by Valid period character strings include: "seconds"
,
"minutes"
, "hours"
, "days"
, "weeks"
,
"months"
, "quarters"
, and "years"
. These are
calclated internally via endpoints
. See that function's help
page for further details.
To adjust the final indexing style, it is possible to set
indexAt
to one of the following: yearmon
, yearqtr
, the first time of the period,
the last time of the period, the starting time in the data for that
period, or the ending time in the data for that period, respectively.
It is also possible to pass a single time series, such as a univariate exchange rate, and return an OHLC object of lower frequency - e.g. the weekly OHLC of the daily series.
Setting drop.time
to TRUE
(the default)
will convert a series that includes a time
component into one with just a date index, as the time index
is often of little value in lower frequency series.
It is not possible to convert a series from a lower periodicity to a higher periodicity - e.g. weekly to daily or daily to 5 minute bars, as that would require magic.
data(sample_matrix)
samplexts <- as.xts(sample_matrix)
to.monthly(samplexts)
to.monthly(sample_matrix)
str(to.monthly(samplexts))
str(to.monthly(sample_matrix))
Run the code above in your browser using DataLab