First post so please forgive any transgressions.
The data (russ_defensive) looks something like this
And this code is meant to create a facet_grid of stacked bars conditionally filled by capitalisation and with axis.text.x colour set to red or black based on whether the industry is defensive or not
library(dplyr)
library(ggplot2)
chart_foo <- ggplot(data = russ_defensive, aes(x = industry)) +
facet_grid(~ sector, space = "free", scales="free") +
geom_bar(stat="count") + aes(fill = capitalisation) +
theme(axis.text.x = element_text(angle = 90, color = ifelse(russ_defensive$defensive_industries == "N", "red", "black")))
Around half of the industries are non-defensive (so russ_defensive$defensive_industries is "N") however this code only turns one of the labels red (see here) and gives the following error:
Warning message:
Vectorized input to `element_text()` is not officially supported.
Results may be unexpected or may change in future versions of ggplot2.
Is there a simple fix to this/ alternate method to conditionally formatting labels based on a column of the dataset?
Thanks for any help, if a reproducible dataset would be useful please let me know.