# xts 週期與時間區間索引

endpoints(matrix_xts,on=’months’)

endpoints(matrix_xts,on=’weeks’)

to.period(matrix_xts,’months’)

periodicity(to.period(matrix_xts,’months’))

to.monthly(matrix_xts)

period.apply(matrix_xts[,4],INDEX=endpoints(matrix_xts),FUN=max) #apply 求速度不是依序 、FUN=max最高價

apply.monthly(matrix_xts[,4],FUN=max) #與上行相同

### endpoints {xts}Locate Endpoints by Time

Description

Extract index values of a given xts object corresponding to the last observations given a period specified by on

Usage

endpoints(x, on=”months”, k=1)

### to.period {xts}Convert time series data to an OHLC series

Description

Convert an OHLC or univariate object to a specified periodicity lower than the given data object. For example, convert a daily series to a monthly series, or a monthly series to a yearly one, or a one minute series to an hourly series.

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.

Usage

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=TRUE,name,…)
to.quarterly(x,indexAt=’yearqtr’,drop.time=TRUE,name,…)
to.yearly(x,drop.time=TRUE,name,…)

to.period(x,
period = ‘months’,
k = 1,
indexAt,
name=NULL,
OHLC = TRUE,
…)

### periodicity {xts}Approximate Series Periodicity

Description

Estimate the periodicity of a time-series-like object by calculating the median time between observations in days.

Usage

periodicity(x, …)

http://blog.fens.me/r-xts/

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.