-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic
appshot.shiny.appobj
functionality (#55)
* add basic appshot.shiny.appob functionality * added schloerke a pull #55 in news and description * added appshot.shiny.appobj and appshot.character to docs * use callr::r_bg to take a webshot of a shiny app and checking in with observe * add timeout * removed processx and withr in favor of callr. fixed rmdshot example. added docs * clean up docs * appshot doc cleanup * make sure timeout is in addition to delay * make sure all r_bg process are killed and upgrade NULL envvars to callr default env * remove render quotes for do.call * add shiny rmdshot example * document
- Loading branch information
Showing
10 changed files
with
252 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ Authors@R: c( | |
person("Winston", "Chang", email = "[email protected]", role = c("aut", "cre")), | ||
person("Yihui", "Xie", role = "ctb"), | ||
person("Francois", "Guillem", role = "ctb"), | ||
person("Barret", "Schloerke", role = "ctb"), | ||
person("Nicolas", "Perriault", role = "ctb", comment = "The CasperJS library") | ||
) | ||
Description: Takes screenshots of web pages, including Shiny applications and R | ||
|
@@ -14,8 +15,7 @@ Depends: | |
Imports: | ||
magrittr, | ||
jsonlite, | ||
withr, | ||
processx | ||
callr | ||
Suggests: | ||
httpuv, | ||
knitr, | ||
|
@@ -27,5 +27,5 @@ SystemRequirements: PhantomJS (http://phantomjs.org) for taking screenshots, | |
ImageMagick (http://www.imagemagick.org) or GraphicsMagick | ||
(http://www.graphicsmagick.org) and OptiPNG (http://optipng.sourceforge.net) | ||
for manipulating images. | ||
RoxygenNote: 6.0.1.9000 | ||
RoxygenNote: 6.0.1 | ||
URL: https://github.com/wch/webshot/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
|
||
r_background_process <- function(..., envvars = NULL) { | ||
if (is.null(envvars)) { | ||
envvars <- callr::rcmd_safe_env() | ||
} | ||
callr::r_bg(..., env = envvars) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: "Shiny Example" | ||
author: "RStudio" | ||
date: "2/28/2018" | ||
output: html_document | ||
runtime: shiny | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
knitr::opts_chunk$set(echo = TRUE) | ||
``` | ||
|
||
This R Markdown document is made interactive using Shiny. Unlike the more traditional workflow of creating static reports, you can now create documents that allow your readers to change the assumptions underlying your analysis and see the results immediately. | ||
|
||
To learn more, see [Interactive Documents](http://rmarkdown.rstudio.com/authoring_shiny.html). | ||
|
||
## Inputs and Outputs | ||
|
||
You can embed Shiny inputs and outputs in your document. Outputs are automatically updated whenever inputs change. This demonstrates how a standard R plot can be made interactive by wrapping it in the Shiny `renderPlot` function. The `selectInput` and `sliderInput` functions create the input widgets used to drive the plot. | ||
|
||
```{r eruptions, echo=FALSE} | ||
inputPanel( | ||
selectInput("n_breaks", label = "Number of bins:", | ||
choices = c(10, 20, 35, 50), selected = 20), | ||
sliderInput("bw_adjust", label = "Bandwidth adjustment:", | ||
min = 0.2, max = 2, value = 1, step = 0.2) | ||
) | ||
renderPlot({ | ||
hist(faithful$eruptions, probability = TRUE, breaks = as.numeric(input$n_breaks), | ||
xlab = "Duration (minutes)", main = "Geyser eruption duration") | ||
dens <- density(faithful$eruptions, adjust = input$bw_adjust) | ||
lines(dens, col = "blue") | ||
}) | ||
``` | ||
|
||
## Embedded Application | ||
|
||
It's also possible to embed an entire Shiny application within an R Markdown document using the `shinyAppDir` function. This example embeds a Shiny application located in another directory: | ||
|
||
```{r tabsets, echo=FALSE} | ||
shinyAppDir( | ||
system.file("examples/06_tabsets", package = "shiny"), | ||
options = list( | ||
width = "100%", height = 550 | ||
) | ||
) | ||
``` | ||
|
||
Note the use of the `height` parameter to determine how much vertical space the embedded application should occupy. | ||
|
||
You can also use the `shinyApp` function to define an application inline rather then in an external directory. | ||
|
||
In all of R code chunks above the `echo = FALSE` attribute is used. This is to prevent the R code within the chunk from rendering in the document alongside the Shiny components. |
Oops, something went wrong.