Description Usage Arguments Details Value Examples
Calculate a vector of equally spaced end points along the elements of a vector, matrix, or time series.
1  calc_endpoints(x_ts, inter_val, stub_front = TRUE)


A vector, matrix, or time series. 

The number of elements between neighboring end points. or a string representing a time period (minutes, hours, days, etc.) 

A Boolean argument: if 
The end points are a vector of integers which divide the elements
(rows) of x_ts
into equally spaced intervals.
If inter_val
is an integer then calc_endpoints()
calculates the number of whole intervals that fit over the elements (rows)
of x_ts
.
If a whole number of intervals doesn't fit over the elements (rows) of
x_ts
, then calc_endpoints()
adds a stub interval either at
the beginning (the default) or at the end.
If inter_val
is a string representing a time period (minutes,
hours, days, etc.), then calc_endpoints()
simply calls the function
endpoints()
from package
xts.
The function calc_endpoints()
is a generalization of function
endpoints()
from package
xts, since
inter_val
can accept both integer and string values.
Similar to xts::endpoints()
, the first integer returned by
calc_endpoints()
is equal to zero.
An integer vector of equally spaced end points (vector of integers).
1 2 3 4 5 6  # Calculate end points with initial stub interval
rutils::calc_endpoints(1:100, inter_val=11)
# Calculate end points with a stub interval at the end
rutils::calc_endpoints(rutils::etf_env$VTI, inter_val=365, stub_front=FALSE)
# Calculate end points at the end of every hour
rutils::calc_endpoints(rutils::etf_env$VTI, inter_val="hours")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.