At work, I’ve developed an internal package to standardize some analysis across the team. Mostly this consists of commonly used functions. I’d also like to add a few ggplot themes and color palettes to this package, but these aren’t functions, they’re objects.
my_palette <- c('blue', 'black', 'red') my_theme <- theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 0.5))
Right now, I just define these at the top of every relevant analysis and then reference them in ggplot:
ggplot(iris) + geom_point(aes(x = Sepal.Length, y = Sepal.Width, color = Species)) + scale_color_manual(values = my_palette) + my_theme
Is there any good way to store objects like this in a package so I can avoid these repetition and also make sure these are standard across the team?