Use unname , so the element passed to par is just a character vector that defines color, not a named element
palette <- c('#002b36','#dc322f','#859900') names(palette) <- c('black','red','green') par(bg=unname(palette['red'])) plot(1:10,1:10,col=palette['green'])

What up to what?
inside par , if all arguments are character vectors, then
if (all(unlist(lapply(args, is.character)))) args <- as.list(unlist(args))
The as.list(unlist(args)) method works if args is a named character vector
args <- list(bg = palette['red']) as.list(unlist(args)) $bg.red [1] "#dc322f"
and bg.red not valid par .
if the string was something like
setNames(as.list(unlist(args, use.names = F)), names(args))
then it can work in some cases (although not if some of the named arg elements had a length> 1)
source share