R - screen() and split.screen(): plot with different sections

26 Aug 2017

# Simulate Data
set.seed(5)
x <- rnorm(100, 50, 25)
y <- -0.3*x^2 + 25*x + 92 + rnorm(100, sd=300)

# Window With 2 Rows, Top Row In 2 Columns
split.screen(c(2,1)) # Makes Screen 1 and 2
split.screen(c(1,2), screen=1) # Makes Screen 3 and 4

# Output On Screen 2
screen(2)
plot(x,y)

# Histograms on Screens 3 and 4
screen(3)
hist(x)
screen(4)
hist(y)

viewed on http://www.rfunction.com/

[ R  plot  function  ]