Add convenience bindings for ggplot2 and plotly with hyperlinks
These functions will probably be moved to a separate package.
Change-Id: Iaecd23b1401bc5df7ee4a904dca2e87466266143
diff --git a/demo/conditionsOverTime.R b/demo/conditionsOverTime.R
index 9f0590d..b23d2bf 100644
--- a/demo/conditionsOverTime.R
+++ b/demo/conditionsOverTime.R
@@ -6,17 +6,19 @@
#install_git("https://korap.ids-mannheim.de/gerrit/KorAP/RKorAPClient", upgrade="never")
library(RKorAPClient)
library(ggplot2)
+library(plotly)
conditionsOverTime <- function(query, conditions, years, kco = new("KorAPConnection", verbose = TRUE)) {
g <- expand_grid(condition = conditions, year = years) %>%
cbind(frequencyQuery(kco, query, sprintf("%s & pubDate in %d", .$condition, .$year))) %>%
ipm() %>%
- ggplot(aes(x = year, y = ipm, fill=condition, color=condition, ymin=conf.low, ymax=conf.high)) +
+ ggplot(aes(x = year, y = ipm, fill=condition, color=condition)) +
geom_freq_by_year_ci() +
xlab("TIME") +
labs(color="Virtual Corpus", fill="Virtual Corpus") +
ylab(sprintf("Observed frequency/million of \u201c%s\u201d", query))
- print(g)
+ p <- RKorAPClient::ggplotly(g)
+ print(p)
}
conditionsOverTime("[tt/l=Heuschrecke]", c("textClass = /natur.*/", "textClass=/politik.*/", "textClass=/wirtschaft.*/"), (2002:2018))