Need Help in Debugging below script:--------------------------------


dat <- get_majorlandmarks(dat,Dmin,Per)
fit_xts <- xts(dat$fit,order.by = dat$Date,frequency = 365)
close_xts <- xts(dat$Close, order.by = dat$Date, frequency = 365 )
majorlandmarks_xts <-xts(dat$Close[dat$majorlandmarks==TRUE], order.by =
dat$Date[dat$majorlandmarks==TRUE], frequency = 365 )
minorlandmarks_xts <-  xts(dat$Close[dat$minorlandmarks==TRUE], order.by =
dat$Date[dat$minorlandmarks==TRUE], frequency = 365 )
landmarkschart_data <-
cbind(close_xts,fit_xts,majorlandmarks_xts,minorlandmarks_xts)



Error:------------- order.by requires an appropriate time-based object

dygraphs::dygraph(landmarkschart_data, xlab = "Time",ylab = "Price") %>%
  dySeries("..1",label = "Close", drawPoints = FALSE,  strokeWidth = 1,
color = "black") %>%
  dySeries("..2",label = "Fit", drawPoints = FALSE,  strokeWidth = 1, color
= "red") %>%
  dySeries("..3",label = "Major LandMarks", drawPoints = TRUE, pointSize =
5, strokeWidth = 0, color = "darkorange") %>%
  dySeries("..4",label = "Minor LandMarks", drawPoints = TRUE, pointSize =
1, strokeWidth = 0, color = "darkblue") %>%
  dyRangeSelector()
###Estimating error with different parameters
# RMSE <- vector()
# for(i in seq(0.01,0.1,0.01)){
#   dat <- get_majorlandmarks(dat,i,0.01)
#   RMSE[i] <- sqrt(sum((dat$fit-dat$Close)^2)/nrow(dat))
# }
# plot(RMSE)

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to