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) |
| 26 | g <- 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() |
| 34 | p <- ggplotly(g) |
| 35 | print(p) |
| 36 | ## saveWidget(p, paste0(tmpdir(), "heuschrecke.html") |
| 37 | |
| 38 | |
| 39 | } |