Add as.alternative parameter to frequencyQuery method
And also rename "tokens" to the more generic "total" in the result
tibble.
Change-Id: Iae2ec16307f993e5b95792f2f66c6a38dc9ff67d
diff --git a/demo/alternativesOverTime.R b/demo/alternativesOverTime.R
index dca55b3..eb85ac8 100755
--- a/demo/alternativesOverTime.R
+++ b/demo/alternativesOverTime.R
@@ -9,9 +9,7 @@
alternativesOverTime <- function(alternatives, years, kco = new("KorAPConnection", verbose=TRUE)) {
df <- expand_grid(Variant = alternatives, year = years) %>%
- cbind(corpusQuery(kco, .$Variant, sprintf("textType = /Zeit.*/ & pubDate in %d", .$year))) %>%
- group_by(year) %>% mutate(tokens = sum(totalResults)) %>%
- ci() %>%
+ cbind(frequencyQuery(kco, .$Variant, sprintf("textType = /Zeit.*/ & pubDate in %d", .$year), as.alternatives=TRUE)) %>%
rename(share=f)
g <- ggplot(data = df, mapping = aes(x = year, y = share, colour = Variant, fill = Variant)) +
geom_freq_by_year_ci() +