hc_freq_by_year_ci: allow additional parameters passed to hc_add_series
for example:
new("KorAPConnection", verbose=T) %>%
frequencyQuery('[orth="Corona-?[vV]ir.*"]',
paste("textType = /Zeit.*/ & creationDate in", (2000:2018))) %>%
hc_freq_by_year_ci(
dataLabels = list(
enabled = TRUE,
format = "({point.count})"
)
)
Change-Id: I1a393d2ea97907d5580f072cf6b2d27b1523ffbb
diff --git a/R/highcharter-helper.R b/R/highcharter-helper.R
index a78f57c..4c40a92 100644
--- a/R/highcharter-helper.R
+++ b/R/highcharter-helper.R
@@ -9,6 +9,7 @@
#' @param df data frame like the value of a \code{\link{frequencyQuery}}
#' @param as.alternatives boolean decides whether queries should be treated as mutually exclusive and exhaustive wrt. to some meaningful class (e.g. spelling variants of a certain word form).
#' @param ylabel defaults to \% if \code{as.alternatives} is \code{true} and to "ipm" otherwise.
+#' @param ... additional arguments passed to \code{\link{hc_add_series}}
#'
#' @examples
#' \donttest{year <- c(1990:2018)}\dontshow{year <- c(2013:2013)}
@@ -33,7 +34,7 @@
#' hc_freq_by_year_ci()
#' }
#'
-hc_freq_by_year_ci <- function(df, as.alternatives = FALSE, ylabel = if(as.alternatives) "%" else "ipm") {
+hc_freq_by_year_ci <- function(df, as.alternatives = FALSE, ylabel = if(as.alternatives) "%" else "ipm", ...) {
title <- ""
df <- df %>%
{ if(! as.alternatives) ipm(.) else RKorAPClient::percent(.) }
@@ -95,13 +96,13 @@
shared = TRUE,
valueSuffix = paste0('\U2009', ylabel)
) %>%
- hc_add_series_korap_frequencies(df, as.alternatives)
+ hc_add_series_korap_frequencies(df, as.alternatives, ...)
}
## Mute notes: "no visible binding for global variable:"
globalVariables(c("value", "query", "condition", "vc"))
-hc_add_series_korap_frequencies <- function(hc, df, as.alternatives = FALSE) {
+hc_add_series_korap_frequencies <- function(hc, df, as.alternatives = FALSE, ...) {
index <- 0
for(q in unique(df$condition)) {
dat <- df[df$condition==q,]
@@ -117,7 +118,8 @@
hcaes(year, value),
type = 'line',
colorIndex = index,
- zIndex = 1
+ zIndex = 1,
+ ...
) %>%
hc_add_series(
name = "ci",
diff --git a/man/hc_freq_by_year_ci.Rd b/man/hc_freq_by_year_ci.Rd
index 273b06f..8e963fe 100644
--- a/man/hc_freq_by_year_ci.Rd
+++ b/man/hc_freq_by_year_ci.Rd
@@ -7,7 +7,8 @@
hc_freq_by_year_ci(
df,
as.alternatives = FALSE,
- ylabel = if (as.alternatives) "\%" else "ipm"
+ ylabel = if (as.alternatives) "\%" else "ipm",
+ ...
)
}
\arguments{
@@ -16,6 +17,8 @@
\item{as.alternatives}{boolean decides whether queries should be treated as mutually exclusive and exhaustive wrt. to some meaningful class (e.g. spelling variants of a certain word form).}
\item{ylabel}{defaults to \% if \code{as.alternatives} is \code{true} and to "ipm" otherwise.}
+
+\item{...}{additional arguments passed to \code{\link{hc_add_series}}}
}
\description{
Experimental convenience function for plotting typical frequency by year graphs with confidence intervals using highcharter.