joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
219 stars 71 forks source link

recycling type #90

Open timelyportfolio opened 9 years ago

timelyportfolio commented 9 years ago

I post this more as a conversation, since this can be easily overcome by adding series than with just one plot call. This might be best handled by an adding an example or some discussion in the documentation. As I was testing out #87, I discovered that recycling type will not work.

library(xts)
data(sample_matrix)
x <- as.xts(sample_matrix)
y <- merge(x,x+1,x+2,x+3)
plot(y,type=c("l","p"))

results in an error with the switch conditional

Error in switch(type, h = { : EXPR must be a length 1 vector
In addition: Warning message:
In if (type == "h" & NCOL(x) > 1) warning("only the univariate series will be plotted") :
  the condition has length > 1 and only the first element will be used
rossb34 commented 9 years ago

This may be an interesting feature to add to a later release so we have some more time to think about and test. It should just work with a basic plot and multiple panels, but I'm not entirely sure. As you point out, you can easily plot several types with calls to lines/points/addSeries and base plot doesn't support a vector for type so I don't think we need to target adding this feature for the upcoming release.

Thanks again for all the testing, your feedback has been very helpful.