I like to plot several charts to files with an identical layout
according to indicators so the charts can be browsed quickly. It is
normal for the indicators in some charts to be completely NA at least
in the range to be plotted. Generating those charts throws

Error in plot.window(c(1, 31), c(NaN, NaN)) : need finite 'ylim' values

To substitute NA by 0, -1 or similar is no option since these are
legal values.

Can I tell R to ignore such errors and simply generate an empty
region instead?

Mike



Minimal reproducible example:

library(quantmod)

data (sample_matrix)
sample.xts <- as.xts (sample_matrix[1:50,'Close'], dateFormat="POSIXct")
sample.xts <- cbind (sample.xts, NA)
sample.xts['2007-02-05::',2] <- 0
sample.xts['2007-02-11',2] <- 1
colnames (sample.xts) <- c('Close', 'Stops')

ta <- list ("add_TA(sample.xts[,2])")

# In the range to be plotted ta is completely NA 
subset <- '2007-01-10::2007-01-30'

plot (chart_Series (sample.xts[,1], subset=subset, TA=ta))

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to