This is because you're passing a numeric vector to CTI(), which can't be converted to an xts object inside CTI(). CTI() calls rollapply(), which doesn't pad the result with leading NA. That's why it has fewer observations than the input. I'll patch TTR so leading NA are added.
In the meantime, you can use this as a work-around. Make sure you have xts version 0.13.1 for as.xts() to automatically find the Date column in ttrc.
library(TTR)
data(ttrc)
ttrc$cti_10 <- CTI(xts::as.xts(ttrc)$Close, n = 10)
EDIT: This is fixed on GitHub now and will be included in the next TTR release. You can install the development version with:
This is because you're passing a numeric vector to
CTI()
, which can't be converted to an xts object insideCTI()
.CTI()
callsrollapply()
, which doesn't pad the result with leading NA. That's why it has fewer observations than the input. I'll patch TTR so leading NA are added.In the meantime, you can use this as a work-around. Make sure you have xts version 0.13.1 for
as.xts()
to automatically find the Date column inttrc
.EDIT: This is fixed on GitHub now and will be included in the next TTR release. You can install the development version with: