I'm trying to define this function to easily set a custom theme to a ggplot, but I'm having trouble using the functions like element_blank()
dynamically.. For example, specifying whether or not to have vertical gridlines as a TRUE/FALSE argument:
qplot(data=df, x=quarter, y=value, geom="line") +
style(grid.vertical = F)
style = function (grid.vertical = T) {
(theme_foundation() +
theme(
panel.grid.major.x = ifelse(grid.vertical == T, element_line(), element_blank())
))}
produces..
Error in (function (el, elname) :
Element panel.grid.major.x must be a element_line object.
Is there a way to make this work?