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{ |
| 7 | ggplotly(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 |
| 14 | in 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 |
| 21 | object with hyperlinks from data points to corresponding KorAP queries. |
| 22 | \bold{Warning:} This function may be moved to a new package. |
| 23 | } |
| 24 | \examples{ |
| 25 | library(ggplot2) |
| 26 | kco <- new("KorAPConnection", verbose=TRUE) |
| 27 | g <- 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() |
| 35 | p <- ggplotly(g) |
| 36 | print(p) |
| 37 | ## saveWidget(p, paste0(tmpdir(), "heuschrecke.html") |
| 38 | |
| 39 | |
| 40 | } |