Use the convenience functions in the demos
Change-Id: I6dd571d92c523e43fecf1f0d183f527da445a7a2
diff --git a/demo/conditionsOverTime.R b/demo/conditionsOverTime.R
index 3f85f8e..9f0590d 100644
--- a/demo/conditionsOverTime.R
+++ b/demo/conditionsOverTime.R
@@ -6,23 +6,17 @@
#install_git("https://korap.ids-mannheim.de/gerrit/KorAP/RKorAPClient", upgrade="never")
library(RKorAPClient)
library(ggplot2)
-library(reshape2)
-#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))) %>%
- ggplot(aes(x = year, y = f, fill=condition, color=condition)) +
- geom_point() +
- geom_line() +
- geom_ribbon(aes(ymin=conf.low, ymax=conf.high, fill=condition, color=condition), alpha=.3, linetype=0) +
+ 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)) +
+ geom_freq_by_year_ci() +
xlab("TIME") +
labs(color="Virtual Corpus", fill="Virtual Corpus") +
- ylab(sprintf("Observed frequency of \u201c%s\u201d", query)) +
- theme(axis.text.x = element_text(angle = 45, hjust = 1)) + scale_x_continuous(breaks=unique(df$year))
+ ylab(sprintf("Observed frequency/million of \u201c%s\u201d", query))
print(g)
- # print(ggplotly(g, tooltip = c("x", "y")))
}
-#df <- conditionsOverTime("wegen dem [tt/p=NN]", c("textClass = /sport.*/", "textClass=/politik.*/", "textClass=/kultur.*/"), (1995:2005))
conditionsOverTime("[tt/l=Heuschrecke]", c("textClass = /natur.*/", "textClass=/politik.*/", "textClass=/wirtschaft.*/"), (2002:2018))