I am trying to print plots to pdf but first received some warning that device 1 cannot be turned off, now I receive only "RStudioGD2". What am I missing here?
This issue with regular R plots is that they are immediately written to the output and cannot be stored in a variable like that. Use the recordPlot to save the current plot output to a variable, then you can save it.
Your function looks a bit weird to me, but that's probably because this is a reprex, not the actual code. You can also consider using ggplot as this is more versatile and powerful than basic plot and you have more control over assigning variables, updating and plotting them.
In ggplot, you need to provide a data frame in the first function and in subsequent functions call any column of it within aes(). Since what your function takes in is a vector, you first need to put it in a data frame then call it again.
I don't know what your goal is, but know that there are other ways of showing multiple plots using gridarrange, though this shows all plots as subplots of a big one.