blob: 7013f05d5d82d521eea3f283dec4097410852de3 [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)
Marc Kupietz05b22772020-02-18 21:58:42 +010026\donttest{year = (2003:2011)}\dontshow{year = (2005:2006)}
Marc Kupietz865760f2019-10-07 19:29:44 +020027g <- expand_grid(condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"),
Marc Kupietz05b22772020-02-18 21:58:42 +010028 year) \%>\%
Marc Kupietz865760f2019-10-07 19:29:44 +020029 cbind(frequencyQuery(kco, "[tt/l=Heuschrecke]",
30 paste0(.$condition," & pubDate in ", .$year))) \%>\%
31 ipm() \%>\%
32 ggplot(aes(year, ipm, fill = condition, color = condition)) +
Marc Kupietz05b22772020-02-18 21:58:42 +010033 ## theme_light(base_size = 20) +
Marc Kupietz865760f2019-10-07 19:29:44 +020034 geom_freq_by_year_ci()
35p <- ggplotly(g)
36print(p)
37## saveWidget(p, paste0(tmpdir(), "heuschrecke.html")
38
39
40}