blob: 5dac932447db9dc76c16d8692727d1ec2a938419 [file] [log] [blame]
Marc Kupietzc4640012020-01-29 17:06:21 +01001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/highcharter-helper.R
Marc Kupietza6e4ee62021-03-05 09:00:15 +01003\name{highcharter-helpers}
4\alias{highcharter-helpers}
Marc Kupietzc4640012020-01-29 17:06:21 +01005\alias{hc_freq_by_year_ci}
Marc Kupietza6e4ee62021-03-05 09:00:15 +01006\alias{hc_add_onclick_korap_search}
7\title{Helper functions for producing highcharts}
Marc Kupietzc4640012020-01-29 17:06:21 +01008\usage{
9hc_freq_by_year_ci(
10 df,
Marc Kupietzcf1771d2020-03-04 16:03:04 +010011 as.alternatives = FALSE,
Marc Kupietz5b503f42020-04-09 15:26:00 +020012 ylabel = if (as.alternatives) "\%" else "ipm",
Marc Kupietzab0b0712020-05-04 16:24:57 +020013 smooth = FALSE,
Marc Kupietz5b503f42020-04-09 15:26:00 +020014 ...
Marc Kupietzc4640012020-01-29 17:06:21 +010015)
Marc Kupietza6e4ee62021-03-05 09:00:15 +010016
17hc_add_onclick_korap_search(hc)
Marc Kupietzc4640012020-01-29 17:06:21 +010018}
19\arguments{
20\item{df}{data frame like the value of a \code{\link{frequencyQuery}}}
21
Marc Kupietz43a6ade2020-02-18 17:01:44 +010022\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 Kupietzc4640012020-01-29 17:06:21 +010023
24\item{ylabel}{defaults to \% if \code{as.alternatives} is \code{true} and to "ipm" otherwise.}
Marc Kupietz5b503f42020-04-09 15:26:00 +020025
Marc Kupietzab0b0712020-05-04 16:24:57 +020026\item{smooth}{boolean decides whether the graph is smoothed using the highcharts plot types spline and areasplinerange.}
27
Marc Kupietz5b503f42020-04-09 15:26:00 +020028\item{...}{additional arguments passed to \code{\link{hc_add_series}}}
Marc Kupietza6e4ee62021-03-05 09:00:15 +010029
30\item{hc}{highchart}
Marc Kupietzc4640012020-01-29 17:06:21 +010031}
32\description{
33Experimental 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 Kupietza6e4ee62021-03-05 09:00:15 +010035
36Adds on-click events to data points of highcarts that were constructed with
37\code{\link{frequencyQuery}} or \code{\link{collocationScoreQuery}}. Clicks on data points
38then launch KorAP web UI queries for the given query term and virtual corpus in
39a separate tab.
Marc Kupietzc4640012020-01-29 17:06:21 +010040}
41\examples{
Marc Kupietz657d8e72020-02-25 18:31:50 +010042\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 Kupietzc4640012020-01-29 17:06:21 +010044new("KorAPConnection", verbose = TRUE) \%>\%
Marc Kupietz657d8e72020-02-25 18:31:50 +010045 frequencyQuery(query = alternatives,
Marc Kupietz05b22772020-02-18 21:58:42 +010046 vc = paste("textType = /Zeit.*/ & pubDate in", year),
Marc Kupietzc4640012020-01-29 17:06:21 +010047 as.alternatives = TRUE) \%>\%
48 hc_freq_by_year_ci(as.alternatives = TRUE)
49
Marc Kupietz05b22772020-02-18 21:58:42 +010050\donttest{
Marc Kupietz10f65c42020-01-31 15:18:24 +010051kco <- new("KorAPConnection", verbose = TRUE)
52expand_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 Kupietz05b22772020-02-18 21:58:42 +010062}
Marc Kupietz10f65c42020-01-31 15:18:24 +010063
Marc Kupietza6e4ee62021-03-05 09:00:15 +010064\donttest{
65library(highcharter)
66library(tidyr)
67
68new("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 Kupietzc4640012020-01-29 17:06:21 +010076}