1

I am experiencing strange behavior of chart_Series(). After a lot of debugging I stripped it down to this:

Working in RStudio, I have data to be plot using chart_Series(), but it does not work in a script.

I believe everything is right on my side. The function is called and there are proper data in the variable I am trying to plot. If I replace chart_Series() with plot() {R}, plota() {SIT}, or even chartSeries() {Quantmod}, everything works as expected. But the new chart_Series() does not.

If I call the chart_Series() function from the console, it works as expected. For example:

chart_Series(x)

but if I copy/paste this single line into Test.R it doesn't work. All the functions listed above do work. Copy/paste back to console, it works again.

SUMMARY: All the charting functions work from a script or console but chart_Series() works only from console.

I know that chart_Series() will replace chartSeries() when the development is done and it is in aplha phase now. Anyway, I find this behavior strange and I expect it to work from a script if it is working in the console. Maybe I am missing something but I have no idea what.

NOTE: I noticed that e.g. head(x) run from console works as expected, but when I try it from a script, it prints nothing to the console. On the other hand, View(x) works from both places. Being new to R/RStudio, I do not know if this is related problem or expected behavior.

jruizaranguren
  • 12,679
  • 7
  • 55
  • 73
Dave
  • 132
  • 1
  • 11
  • [Wrap the call in `plot`](http://stackoverflow.com/a/13538394/271616). – Joshua Ulrich Jan 02 '15 at 16:36
  • Just great. Thank you very much, Joshua. Is this a workaround or expected behavior? I am also new here on stackoverflow.com but I think if you post a reply not just comment I can mark it as the right answer. – Dave Jan 02 '15 at 16:42
  • It's expected, and is the case with many plotting functions, not just `chart_Series`. I don't currently have time to write a full answer... and I'm not particularly interested in doing so, since I've answered this question dozens of times in various forums. :) – Joshua Ulrich Jan 02 '15 at 16:44
  • Thank you again and sorry for asking. I really spent hours googling and trying to debug and solve the problem before writing this question. I had it deep in R6 classes with some methods involved and it took some time to realize how simple the basic problem is. Really, thank you. – Dave Jan 02 '15 at 17:06
  • You're welcome and no need to apologize. I was just letting you know why I wasn't going to answer. You could write a comprehensive answer yourself after you get enough reputation. – Joshua Ulrich Jan 02 '15 at 17:22
  • And when an answer is written up, please do reference the relevant item in the R-FAQ. – IRTFM Jan 02 '15 at 18:06

0 Answers0