'Pass changing column names into a list

I have a shinyApp in which I want to visualize some data. The graphics function requires a colors argument, which is a list of the column names of the data frame going into the function and the corresponding colors. However, since the number of column names and the column names itself can be quite different due to user interactivity, I don't know how to put them into the colors argument's list.

library(tibble)

tibble::tibble(columnOne=1, columnTwo=2, columnThree=3)

tbl %>%
grapicFunction(data = ., colors = list(columnOne = "red", columnTwo = "green", columnThree = "yellow"))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source