On a generic plot, with time on the x-axis, I would like to highlight a period of some specific years.
How can I bestly do this? My idea is for example a light yello
You can use the chartSeries() function in quantmod with an xts timeSeries and the addTA() function to add the background highlighting:
chartSeries()
quantmod
xts
addTA()
addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333", border=NA)