blob: bd0d04be62065b00adcbd544ac4ac83c6f4ed239 [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{
Marc Kupietz76685f52019-11-25 17:46:06 +01007ggplotly(p = ggplot2::last_plot(), tooltip = c("x", "y", "colour", "url"), ...)
Marc Kupietz865760f2019-10-07 19:29:44 +02008}
9\arguments{
10\item{p}{a ggplot object.}
11
12\item{tooltip}{a character vector specifying which aesthetic mappings to show
13in the tooltip. If you want hyperlinks to KorAP queries you need to include
14\code{"url"} here.}
15
16\item{...}{Other arguments passed to \code{plotly::ggplotly}}
17}
18\description{
19\code{RKorAPClient::ggplotly} converts a \code{ggplot2::ggplot()} object to a plotly
20object with hyperlinks from data points to corresponding KorAP queries.
21\bold{Warning:} This function may be moved to a new package.
22}
23\examples{
24library(ggplot2)
25kco <- new("KorAPConnection", verbose=TRUE)
26g <- expand_grid(condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"),
27 year = (2002:2018)) \%>\%
28 cbind(frequencyQuery(kco, "[tt/l=Heuschrecke]",
29 paste0(.$condition," & pubDate in ", .$year))) \%>\%
30 ipm() \%>\%
31 ggplot(aes(year, ipm, fill = condition, color = condition)) +
32## theme_light(base_size = 20) +
33 geom_freq_by_year_ci()
34p <- ggplotly(g)
35print(p)
36## saveWidget(p, paste0(tmpdir(), "heuschrecke.html")
37
38
39}