I have an R dataframe (named frequency
) like this:
word author proportion
a Radicals 1.679437e-04
aa Radicals 2.099297e-04
aaa Radicals 2.099297e-05
abbe Radicals NA
aboow Radicals NA
about Radicals NA
abraos Radicals NA
ytterst Conservatives 5.581042e-06
yttersta Conservatives 5.581042e-06
yttra Conservatives 2.232417e-05
yttrandefrihet Conservatives 5.581042e-06
yttrar Conservatives 2.232417e-05
I want to plot document differences using ggplot2. Something like this
I have the code below, but my plot ends up empty.
library(scales)
ggplot(frequency, aes(x = proportion, y = `Radicals`, color = abs(`Radicals` - proportion))) +
geom_abline(color = "gray40", lty = 2) +
geom_jitter(alpha = 0.1, size = 2.5, width = 0.3, height = 0.3) +
geom_text(aes(label = word), check_overlap = TRUE, vjust = 1.5) +
scale_x_log10(labels = percent_format()) +
scale_y_log10(labels = percent_format()) +
scale_color_gradient(limits = c(0, 0.001), low = "darkslategray4", high = "gray75") +
facet_wrap(~author, ncol = 2) +
theme(legend.position="none") +
labs(y = "Radicals", x = NULL)