Unable to retrieve multiple panel charts with chartSeries function from the quant package in R

Quantmod Jeff Ryan is a great contribution to the world of finance R.

I like to use the chartSeries () function, but when I try to get it to display multiple panels at the same time, this will not work.

par(mfrow=c(2,2))

chartSeries (SPX)
chartSeries (SPX, subset="2010")

chartSeries (NDX)
chartSeries (NDX, subset="2010")

usually returns a four-panel graphic, as with the plot () function, but in the chartSeries example, it runs through all instances one at a time, without creating a single four-panel graphic.

+3
source share
3 answers

use chart_Series () instead of chartSeries (), this is a match between layout () and par ().

+4
source

No, unfortunately, you cannot (unless this has changed recently).

, , .

, par(mfrow=...) ..

0

I just add to Brian G. Peterson a message about a working example of quantum code code for creating graphs chart_Seriesin several panels:

# download data and copy it into environment
sym_bols <- c("IEF", "VTI", "XLP", "XLF", "XLK", "VXX")
data_env <- new.env()
quantmod::getSymbols(sym_bols, env=data_env, from="2017-01-01")
# create chart_Series plots in multiple panels
x11()
par(mfrow=c(3, 2))
par(mar=c(2, 2, 2, 1), oma=c(0, 0, 0, 0))
eapply(data_env, function(x) {
  plot(quantmod::chart_Series(x["2017-06/"], 
       name=strsplit(colnames(x)[1], split="[.]")[[1]][1]))
})  # end eapply

Note what chart_Seriesyou need to wrap in plot.

It produces the following graph:

enter image description here

0
source

Source: https://habr.com/ru/post/1744582/


All Articles