blob: 7aedff6ba64abf576653263af34e083d6ed41a78 [file] [log] [blame]
Marc Kupietz865760f2019-10-07 19:29:44 +02001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/misc.R
3\name{ggplotly}
4\alias{ggplotly}
5\title{Experimental: Convert ggplot2 to plotly with hyperlinks to KorAP queries}
6\usage{
7ggplotly(p = ggplot2::last_plot(), tooltip = c("x", "y", "colour",
8 "url"), ...)
9}
10\arguments{
11\item{p}{a ggplot object.}
12
13\item{tooltip}{a character vector specifying which aesthetic mappings to show
14in the tooltip. If you want hyperlinks to KorAP queries you need to include
15\code{"url"} here.}
16
17\item{...}{Other arguments passed to \code{plotly::ggplotly}}
18}
19\description{
20\code{RKorAPClient::ggplotly} converts a \code{ggplot2::ggplot()} object to a plotly
21object with hyperlinks from data points to corresponding KorAP queries.
22\bold{Warning:} This function may be moved to a new package.
23}
24\examples{
25library(ggplot2)
26kco <- new("KorAPConnection", verbose=TRUE)
27g <- expand_grid(condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"),
28 year = (2002:2018)) \%>\%
29 cbind(frequencyQuery(kco, "[tt/l=Heuschrecke]",
30 paste0(.$condition," & pubDate in ", .$year))) \%>\%
31 ipm() \%>\%
32 ggplot(aes(year, ipm, fill = condition, color = condition)) +
33## theme_light(base_size = 20) +
34 geom_freq_by_year_ci()
35p <- ggplotly(g)
36print(p)
37## saveWidget(p, paste0(tmpdir(), "heuschrecke.html")
38
39
40}