Marc Kupietz | 865760f | 2019-10-07 19:29:44 +0200 | [diff] [blame] | 1 | % 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 Kupietz | 76685f5 | 2019-11-25 17:46:06 +0100 | [diff] [blame] | 7 | ggplotly(p = ggplot2::last_plot(), tooltip = c("x", "y", "colour", "url"), ...) |
Marc Kupietz | 865760f | 2019-10-07 19:29:44 +0200 | [diff] [blame] | 8 | } |
| 9 | \arguments{ |
| 10 | \item{p}{a ggplot object.} |
| 11 | |
| 12 | \item{tooltip}{a character vector specifying which aesthetic mappings to show |
| 13 | in 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 |
| 20 | object with hyperlinks from data points to corresponding KorAP queries. |
| 21 | \bold{Warning:} This function may be moved to a new package. |
| 22 | } |
| 23 | \examples{ |
| 24 | library(ggplot2) |
| 25 | kco <- new("KorAPConnection", verbose=TRUE) |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 26 | \donttest{year = (2003:2011)}\dontshow{year = (2005:2006)} |
Marc Kupietz | 865760f | 2019-10-07 19:29:44 +0200 | [diff] [blame] | 27 | g <- expand_grid(condition = c("textDomain = /Wirtschaft.*/", "textDomain != /Wirtschaft.*/"), |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 28 | year) \%>\% |
Marc Kupietz | 865760f | 2019-10-07 19:29:44 +0200 | [diff] [blame] | 29 | cbind(frequencyQuery(kco, "[tt/l=Heuschrecke]", |
| 30 | paste0(.$condition," & pubDate in ", .$year))) \%>\% |
| 31 | ipm() \%>\% |
| 32 | ggplot(aes(year, ipm, fill = condition, color = condition)) + |
Marc Kupietz | 05b2277 | 2020-02-18 21:58:42 +0100 | [diff] [blame] | 33 | ## theme_light(base_size = 20) + |
Marc Kupietz | 865760f | 2019-10-07 19:29:44 +0200 | [diff] [blame] | 34 | geom_freq_by_year_ci() |
| 35 | p <- ggplotly(g) |
| 36 | print(p) |
| 37 | ## saveWidget(p, paste0(tmpdir(), "heuschrecke.html") |
| 38 | |
| 39 | |
| 40 | } |