Hi Guys,
I'm trying to manage xts objects in particular merge xts objects.
I built a first xts object called stock, and I build performance indicator RDP_5 (a new xts object)
I create a new xts object y1 based on RDP_5.
When I truy to combine the 2 objects: RDP_5 and y1 in xts object called xts1. It doesn't wok. The time indexes are the same. A warning message appears:
In merge.xts(..., all = all, fill = fill, suffixes = suffixes)
NAs introduced by coercion
I would appreciate if someone could shed me some insights to handle my issue as I am new to R
Best
library(pdfetch)
library(xts)
stock<-pdfetch_YAHOO("FP.PA", from = as.Date("2015-01-01"), to = as.Date("2019-03-31"))
colnames(stock)<- c("open","high","low", "close", "adjclose", "volume")
dates <- index(stock)
nb=nrow(stock)
#calculus
RDP_5=matrix(NA,nb,1)
RDP_5=xts(RDP_5, time(stock))
RDP_5=100*diff(stock[,4], lag=5, arithmetic=FALSE, log=TRUE)
colnames(RDP_5)<-"RDP5"
y1=matrix(NA,nb)
y1=xts(x=y1, order.by=dates)
for (i in 1:nb){
temp=RDP_5[i]
y1[i]=ifelse(-temp>4,"low", "high")
}
xts1=cbind(RDP_5, y1)