Q:

Simplify plot() code in R

When I add multiiple lines to a plot the code blows up like this.
plot_pch = 16
plot_ltya = 'solid'
plot_ltyb = 'dotted'

plot(df[cond1, 'field'], 
     type='o',
     pch=plot_pch,
     plot_ltya)
lines(df[cond2, 'field'],
      type='o',      
      pch=plot_pch,
      lty=plot_ltya)
lines(df[cond3, 'field'],
      type='o',      
      pch=plot_pch,
      lty=plot_ltya)
lines(df[cond4, 'field'],
      type='o',      
      pch=plot_pch,
      lty=plot_ltyb)
lines(df[cond5, 'field'],
      type='o',      
      pch=plot_pch,
      lty=plot_ltyb)

Is there a way to simplyfy that with kind of global settings?
setglobal(pch=plot_pch)

A:

If you want to change a graphical parameter (like pch) for the remainder of an R session you can do the following:
plot_pch <- 16
par(pch = plot_pch)

After setting the pch value, another way to simplify this call would be to use the mapply function:
plot(df[cond1, 'field'], 
     type='o',
     pch=plot_pch,
     lty = 'solid')

mapply(function(df, lty) lines(df, type = 'o', lty = lty), 
df = list(df[cond2, 'field'], df[cond3, 'field'], 
          df[cond4, 'field'], df[cond5, 'field']), 
lty = rep(c('solid','dotted'), each = 2))

