rquantmodess

Display four lineChart() in different windows or simultaneously in R and ESS, quantmod


How can I display these four lineChart() simultaneously or in one window ?

Having this code in one file:

library(quantmod)

getSymbols("XPT/USD",src="oanda") 
getSymbols("XAU/USD",src="oanda")

lineChart(XAUUSD, subset='2018-03::2018-03') 
lineChart(XAUUSD, subset='2018-04::2018-04') 
lineChart(XPTUSD, subset='2018-03::2018-03')
lineChart(XPTUSD, subset='2018-04::2018-04')

When I evaluate the buffer it displays only the last lineChart.

Is this a property of ESS ? I want to clarify that I need the four graphs separately.


Solution

  • The quantmod plotting functions, nice and powerful as they are, will not respect par(c(mfrow())) or the equally nice (but less well-known layout()) so you have to create new plotting devices -- via x11() or window()-- and arrange them via your operating system / window manager.

    For me:

    R> x11(); lineChart(XAUUSD, subset='2018-03::2018-03')
    R> x11(); lineChart(XAUUSD, subset='2018-04::2018-04') 
    R> x11(); lineChart(XPTUSD, subset='2018-03::2018-03')
    R> x11(); lineChart(XPTUSD, subset='2018-04::2018-04')
    

    yielded

    enter image description here

    and note that these are four distinct window. See dev.new() and dev.next() and those functions.