When I run function CTI(Close ,n=10)
, it show Caused by error:!
cti_10 must be size 5550 or 1, not 5541.
. How to fix it ? Thanks!
library(tidyverse)
library(TTR)
data(ttrc)
ttrc %>% mutate( cti_10 = CTI(Close ,n=10))
When I run function CTI(Close ,n=10)
, it show Caused by error:!
cti_10 must be size 5550 or 1, not 5541.
. How to fix it ? Thanks!
library(tidyverse)
library(TTR)
data(ttrc)
ttrc %>% mutate( cti_10 = CTI(Close ,n=10))
Copyright © 2021 Jogjafile Inc.
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: