r - Using a variable in a manual colour palette -
i've got variable called team
team <- "denver"
i want use in manual colour scheme.
colours.manual <- c(team = "green", "draw" = "grey", "other team" = "red")
the problem here colours.manual assigns green team instead of denver.
what need use variable?
thanks
we can use setnames
colours.manual <- setnames(c("green", "grey", "red"), c(team, "draw", "other team")) colours.manual # denver draw other team # "green" "grey" "red"
Comments
Post a Comment