Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
| 2 | % Please edit documentation in R/highcharter-helper.R |
Marc Kupietz | a6e4ee6 | 2021-03-05 09:00:15 +0100 | [diff] [blame] | 3 | \name{highcharter-helpers} |
| 4 | \alias{highcharter-helpers} |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 5 | \alias{hc_freq_by_year_ci} |
Marc Kupietz | a6e4ee6 | 2021-03-05 09:00:15 +0100 | [diff] [blame] | 6 | \alias{hc_add_onclick_korap_search} |
| 7 | \title{Helper functions for producing highcharts} |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 8 | \usage{ |
| 9 | hc_freq_by_year_ci( |
| 10 | df, |
Marc Kupietz | cf1771d | 2020-03-04 16:03:04 +0100 | [diff] [blame] | 11 | as.alternatives = FALSE, |
Marc Kupietz | 5b503f4 | 2020-04-09 15:26:00 +0200 | [diff] [blame] | 12 | ylabel = if (as.alternatives) "\%" else "ipm", |
Marc Kupietz | ab0b071 | 2020-05-04 16:24:57 +0200 | [diff] [blame] | 13 | smooth = FALSE, |
Marc Kupietz | 5b503f4 | 2020-04-09 15:26:00 +0200 | [diff] [blame] | 14 | ... |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 15 | ) |
Marc Kupietz | a6e4ee6 | 2021-03-05 09:00:15 +0100 | [diff] [blame] | 16 | |
| 17 | hc_add_onclick_korap_search(hc) |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 18 | } |
| 19 | \arguments{ |
| 20 | \item{df}{data frame like the value of a \code{\link{frequencyQuery}}} |
| 21 | |
Marc Kupietz | 43a6ade | 2020-02-18 17:01:44 +0100 | [diff] [blame] | 22 | \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).} |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 23 | |
| 24 | \item{ylabel}{defaults to \% if \code{as.alternatives} is \code{true} and to "ipm" otherwise.} |
Marc Kupietz | 5b503f4 | 2020-04-09 15:26:00 +0200 | [diff] [blame] | 25 | |
Marc Kupietz | ab0b071 | 2020-05-04 16:24:57 +0200 | [diff] [blame] | 26 | \item{smooth}{boolean decides whether the graph is smoothed using the highcharts plot types spline and areasplinerange.} |
| 27 | |
Marc Kupietz | 5b503f4 | 2020-04-09 15:26:00 +0200 | [diff] [blame] | 28 | \item{...}{additional arguments passed to \code{\link{hc_add_series}}} |
Marc Kupietz | a6e4ee6 | 2021-03-05 09:00:15 +0100 | [diff] [blame] | 29 | |
| 30 | \item{hc}{highchart} |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 31 | } |
| 32 | \description{ |
| 33 | Experimental convenience function for plotting typical frequency by year graphs with confidence intervals using highcharter. |
| 34 | \bold{Warning:} This function may be moved to a new package. |
Marc Kupietz | a6e4ee6 | 2021-03-05 09:00:15 +0100 | [diff] [blame] | 35 | |
Marc Kupietz | 9dc1d9f | 2021-03-08 14:25:23 +0100 | [diff] [blame] | 36 | Adds on-click events to data points of highcharts that were constructed with |
Marc Kupietz | a6e4ee6 | 2021-03-05 09:00:15 +0100 | [diff] [blame] | 37 | \code{\link{frequencyQuery}} or \code{\link{collocationScoreQuery}}. Clicks on data points |
| 38 | then launch KorAP web UI queries for the given query term and virtual corpus in |
| 39 | a separate tab. |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 40 | } |
| 41 | \examples{ |
Marc Kupietz | 657d8e7 | 2020-02-25 18:31:50 +0100 | [diff] [blame] | 42 | \donttest{year <- c(1990:2018)}\dontshow{year <- c(2013:2013)} |
| 43 | \donttest{alternatives <- c("macht []{0,3} Sinn", "ergibt []{0,3} Sinn")}\dontshow{alternatives <- c("macht []{0,3} Sinn")} |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 44 | new("KorAPConnection", verbose = TRUE) \%>\% |
Marc Kupietz | 657d8e7 | 2020-02-25 18:31:50 +0100 | [diff] [blame] | 45 | frequencyQuery(query = alternatives, |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 46 | vc = paste("textType = /Zeit.*/ & pubDate in", year), |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 47 | as.alternatives = TRUE) \%>\% |
| 48 | hc_freq_by_year_ci(as.alternatives = TRUE) |
| 49 | |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 50 | \donttest{ |
Marc Kupietz | 10f65c4 | 2020-01-31 15:18:24 +0100 | [diff] [blame] | 51 | kco <- new("KorAPConnection", verbose = TRUE) |
| 52 | expand_grid( |
| 53 | condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"), |
| 54 | year = (2005:2011) |
| 55 | ) \%>\% |
| 56 | cbind(frequencyQuery( |
| 57 | kco, |
| 58 | "[tt/l=Heuschrecke]", |
| 59 | paste0(.$condition, " & pubDate in ", .$year) |
| 60 | )) \%>\% |
| 61 | hc_freq_by_year_ci() |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 62 | } |
Marc Kupietz | 10f65c4 | 2020-01-31 15:18:24 +0100 | [diff] [blame] | 63 | |
Marc Kupietz | a6e4ee6 | 2021-03-05 09:00:15 +0100 | [diff] [blame] | 64 | \donttest{ |
| 65 | library(highcharter) |
| 66 | library(tidyr) |
| 67 | |
| 68 | new("KorAPConnection", verbose = TRUE) \%>\% |
| 69 | collocationScoreQuery("Team", "agil", vc = paste("pubDate in", c(2014:2018)), |
| 70 | lemmatizeNodeQuery = TRUE, lemmatizeCollocateQuery = TRUE) \%>\% |
| 71 | pivot_longer(c("O", "E")) \%>\% |
| 72 | hchart(type="spline", hcaes(label, value, group=name)) \%>\% |
| 73 | hc_add_onclick_korap_search() |
| 74 | } |
| 75 | |
Marc Kupietz | c464001 | 2020-01-29 17:06:21 +0100 | [diff] [blame] | 76 | } |