endpoints() throws an error when not k > 0 for all cases of on except of the following: years, quarters and months. This is because the error is raised on the cases where the C implementation is used which checks for the values of k.
The case of on = months is an exception as here the C implementation is used but the k value is fixed at 1L.
The cases of on = quarters or on = years are using the R implementation and they don't check for k > 0.
Examples
library(xts)
xx <- as.xts(1:30,
seq.Date(as.Date(Sys.Date()),
by = "day",
length.out = 30))
Error is raised when not k > 0
endpoints(xx, on = "ms", k = -1)
# Error in endpoints(xx, on = "ms", k = -1) : 'k' must be > 0
endpoints(xx, on = "minutes", k = -1)
# Error in endpoints(xx, on = "minutes", k = -1) : 'k' must be > 0
endpoints(xx, on = "days", k = -1)
# Error in endpoints(xx, on = "days", k = -1) : 'k' must be > 0
endpoints(xx, on = "week", k = -1)
# Error in endpoints(xx, on = "week", k = -1) : 'k' must be > 0
Error is not raised when not k > 0
endpoints(xx, on = "months", k = -1)
> [1] 0 29 30
endpoints(xx, on = "quarters", k = -1)
> [1] 0 29 30
endpoints(xx, on = "years", k = -1)
> [1] 0 30
endpoints()
throws an error when notk > 0
for all cases ofon
except of the following:years
,quarters
andmonths
. This is because the error is raised on the cases where theC
implementation is used which checks for the values ofk
.The case of
on = months
is an exception as here theC
implementation is used but thek
value is fixed at1L
.The cases of
on = quarters
oron = years
are using theR
implementation and they don't check fork > 0
.Examples
Error is raised when not
k > 0
Error is not raised when not
k > 0