-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
57 lines (48 loc) · 1.6 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
# First Steps With The Shiny R Package
<!-- badges: start -->
[![License](https://img.shields.io/github/license/mcanouil/rshiny)](LICENSE)
<!-- badges: end -->
This is a workshop for the R package `shiny`.
```{r, include = FALSE}
library(magick)
library(here)
library(chromote)
library(glue)
thumb <- "thumbs/title_slide_thumb.png"
png <- sub("_thumb", "", thumb)
index_html <- here::here("docs/index.html")
if (!file.exists(thumb) | file.mtime(thumb) < file.mtime(index_html)) {
web_browser <- suppressMessages(try(chromote::ChromoteSession$new(), silent = TRUE))
if (inherits(web_browser, "try-error") && Sys.info()[["sysname"]] == "Windows") {
edge_path <- "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
if (file.exists(edge_path)) {
Sys.setenv(CHROMOTE_CHROME = edge_path)
web_browser <- chromote::ChromoteSession$new()
} else {
stop('Please set Sys.setenv(CHROMOTE_CHROME = "Path/To/Chrome")')
}
}
web_browser$Page$navigate(index_html, wait_ = FALSE)
page_browser <- web_browser$Page$loadEventFired()
Sys.sleep(1)
web_browser$screenshot(
filename = png,
selector = "div.remark-slide-scaler",
scale = 2
)
web_browser$close()
resize <- function(path_in, path_out) {
image <- image_read(path_in)
image <- image_resize(image, "384x")
image_write(image, path_out)
}
resize(png, thumb)
}
```
```{r, results = "asis", echo = FALSE}
glue::glue('<a href="{png}"><img alt="Title Slide" src="{thumb}" width="384" height="216"></a>')
```