class: center, middle, inverse, title-slide # RaukR presentation demo ## RaukR 2021 • Advanced R for Bioinformatics ###
Roy Francis
### NBIS, SciLifeLab --- exclude: true count: false <link href="https://fonts.googleapis.com/css?family=Roboto|Source+Sans+Pro:300,400,600|Ubuntu+Mono&subset=latin-ext" rel="stylesheet"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous"> <!-- ----------------- Only edit title & author above this ----------------- --> --- name: content class: spaced ## Contents * [RMarkdown](#intro_rmarkdown) * [Slides](#slides) * [Layout](#layout) * [Text formatting](#text_formatting_1) * [Code formatting](#code) * [Lists](#lists) * [Images](#images_markdown) * [Math expressions](#math) * [Tables](#table_kable) * [Static plots](#plot_static_base) * [Interactive plots](#plot_interactive_highcharter) * [Maps](#plot_interactive_leaflet) * [Crosstalk](#plot_interactive_crosstalk) * [General tips](#tips) --- name: intro class: middle, spaced ## Introduction <div class="abstract"> .medium[This is a demo to showcase the __RaukR presentation design guide__, __usage__ and capabilities of this presentation system. This presentation is created in RStudio using R package __[xaringan](https://github.com/yihui/xaringan)__. This package in turn utilises the javascript library __[remarkjs](https://github.com/yihui/xaringan)__ as the underlying framework. Note that the markdown interpreter used by remarkjs (blackfriday) is different from that used by knitr (pandoc). Therefore, some features that you may be familiar with in regular RMarkdown may not work here. There are also many new features here not available in regular RMarkdown.] .medium[Note that many of the classes used in this presentation are custom built and not part of any standard package.] </div> --- name: intro_rmarkdown ## RMarkdown * This is an RMarkdown presentation. * Markdown is a simple formatting syntax for authoring documents exported to HTML, PDF etc. * In RStudio, you create a `.Rmd` text file. * Add YAML matter to the top if not already there. ``` --- title: "This is a title" output: xaringan::moon_reader --- ``` * Click the **Knit** button for interactive render. * Or using `render()` as such: ```r rmarkdown::render("report.Rmd",output_format="html_document") ``` --- name: slides ## Slides __Slide separators__ Slides are separated by `---`. Incremental content on same slide is separated by `--` like below. -- __Slide properties__ Slides can be named. ``` --- name: intro ``` and then hyperlinked from elsewhere. For eg: `go to [introduction](#intro)` displayed as go to [introduction](#intro). Custom classes can be defined for each slide. ``` --- class: spaced ``` Few default options are _spaced_ (increases line spacing), _middle_ (center aligns content vertically) and _center_ (center aligns content horizontally). Slides can be hidden using `exclude: true`. Slides can be dropped from page count using `count: false`. -- __Slide notes__ Any content below `???` on a slide are notes. This is only visible in presenter mode (by pressing __P__). -- __Keyboard shortcuts__ Press __H__ to view keyboard shorcuts. Pressing __C__ clones and creates two linked presentations. ??? Here are some slide notes. Press **P** again to exit presenter mode. --- name: layout ## Layout The slide content can be organised into columns which can be nested if needed. Classes for 30, 40, 50, 60 and 70 have been implemented for left and right. Note that the total width must sum to 100. ``` .pull-left-50[ <div style="background-color:#fdebd0">Left content</div> ] .pull-right-50[ <div style="background-color:#eaf2f8">Right content</div> .pull-left-60[ <div style="background-color:#d0ece7">Inner left content</div> ] .pull-right-40[ <div style="background-color:#f2d7d5">Inner right content</div> ] ] ``` .pull-left-50[ <div style="background-color:#fdebd0">Left content</div> ] .pull-right-50[ <div style="background-color:#eaf2f8">Right content</div> .pull-left-60[ <div style="background-color:#d0ece7">Inner left content</div> ] .pull-right-40[ <div style="background-color:#f2d7d5 ">Inner right content</div> ] ] --- name: layout-2 ## Custom Divs ``` <div class="abstract"> This is a special box. </div> ``` <div class="abstract"> This is a special box. </div> --- name: text_formatting_1 ## Text Formatting .pull-left-50[ Headings can be defined as shown below. ``` ## Level 2 heading ### Level 3 heading #### Level 4 heading ##### Level 5 heading ###### Level 6 heading ``` ## Level 2 heading ### Level 3 heading #### Level 4 heading ##### Level 5 heading ###### Level 6 heading Level 1 usage is not recommended. Use level 2 for slide titles. Use level 3 and below for other titles. ] .pull-right-50[ Six custom classes are defined for text scaling. ``` .largest[Largest text.] .larger[Larger text.] .large[Large text.] Normal text. .small[Small text] .smaller[Smaller text.] .smallest[Smallest text.] ``` .largest[Largest text.] .larger[Larger text.] .large[Large text.] Normal text. .small[Small text.] .smaller[Smaller text.] .smallest[Smallest text.] ] --- name: text_formatting_2 ## Text Formatting .pull-left-50[ Horizontal alignment of text can be adjusted as shown below. ``` .left[Left aligned text.] .center[Center aligned text.] .right[Right aligned text.] ``` .left[Left aligned text.] .center[Center aligned text.] .right[Right aligned text.] Indented quotes using `>` > This line is blockquoted Icons from [FontAwesome](https://fontawesome.com/v5.0.13/icons?d=gallery) can be displayed using the HTML `<i>` tag. Note that not all icons may work. `Here is a <i class='fa fa-calendar'></i> calendar and a <i class='fa fa-couch'></i> couch.` Here is a <i class='fa fa-calendar'></i> calendar and a <i class='fa fa-couch'></i> couch. ] .pull-right-50[ A horizontal line can be created using `***` *** `This is __Bold text__` This is __Bold text__ `This is _Italic text_` This is _Italic text_ `~~Strikethrough~~ text` ~~Strikethrough~~ text This is Subscript `H<sub>2</sub>O` displayed as H<sub>2</sub>O This is Superscript `2<sup>10</sup>` displayed as 2<sup>10</sup> `This is a [link](r-project.org)` This is a [link](r-project.org) ] --- name: code ## Code formatting .pull-left-50[ Code can be defined inline where `` `this` `` looks like `this`. R code can be executed inline `` `r Sys.Date()` `` producing 2022-04-13. Code can also be defined inside code blocks. <pre class="smaller"> ``` This is code ``` </pre> ``` This is code ``` R code is executed inside code blocks like this ```` ```{r} Sys.Date() ``` ```` which shows the code and output. ```r Sys.Date() ``` ``` ## [1] "2022-04-13" ``` The code and results can be hidden by `` ```{r,echo=FALSE,results='hide'}` ``. ] .pull-right-50[ ```r data(iris) head(iris[,1:2]) ``` ``` ## Sepal.Length Sepal.Width ## 1 5.1 3.5 ## 2 4.9 3.0 ## 3 4.7 3.2 ## 4 4.6 3.1 ## 5 5.0 3.6 ## 6 5.4 3.9 ``` ] --- name: lists ## Lists __Bulleted List__ Bullet points are defined using the asterisk (*). ``` ** Bullet 1 ** Bullet 2 + Sub-bullet 2.1 ``` * Bullet 1 * Bullet 2 + Sub-bullet 2.1 -- __Incremental Bullets__ ``` ** Incremental Bullet 1 -- ** Incremental Bullet 2 -- ** Incremental Bullet 3 ``` Note that there is an empty line between the bullet point and the `--` below. -- * Incremental Bullet 1 -- * Incremental Bullet 2 -- * Incremental Bullet 3 --- name: images_markdown ## Images • Markdown __Using Markdown__ .pull-left-50[ Using regular markdown. ```  ```  The dimensions are based on image and/or fill up the entire available space. You have no control over the displayed dimensions. ] .pull-right[ Custom classes can be used to control size. ``` .size-20[] .size-10[] ``` .size-20[] .size-10[] The number denotes % of the original dimension. The following size classes are implemented: 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95. ] --- name: images_html ## Images • HTML __Using Raw HTML__ This image is 30% size. `<img src="assets/cover.jpg" style="width:30%;"/>` <img src="assets/cover.jpg" style="width:30%;"/> This image is 30% size, has shadow and corners rounded. `<img src="assets/cover.jpg" style="width:30%;" class="fancyimage"/>` <img src="assets/cover.jpg" style="width:30%;" class="fancyimage"/> --- name: images_r ## Images • R __Using R__ R chunks in RMarkdown can be used to control image display size using the arguemnt `out.width`. This image is displayed at a size of 200 pixels. ```` ```{r,out.width=200} knitr::include_graphics('assets/cover.jpg') ``` ```` <img src="assets/cover.jpg" width="200" style="display: block; margin: auto auto auto 0;" /> This image is displayed at a size of 75 pixels. ```` ```{r,out.width=75} knitr::include_graphics('assets/cover.jpg') ``` ```` <img src="assets/cover.jpg" width="75" style="display: block; margin: auto auto auto 0;" /> --- name: math ## Math expressions Some examples of rendering equations. .pull-left-40[ `\(e^{i\pi} + 1 = 0\)` `$$\frac{E \times X^2 \prod I}{2+7} = 432$$` `$$\sum_{i=1}^n X_i$$` `$$\int_0^{2\pi} \sin x~dx$$` ] .pull-right-60[ `\(\left( \sum_{i=1}^{n}{i} \right)^2 = \left( \frac{n(n-1)}{2}\right)^2 = \frac{n^2(n-1)^2}{4}\)` `\(\begin{eqnarray} X & \sim & \mathrm{N}(0,1)\\ Y & \sim & \chi^2_{n-p}\\ R & \equiv & X/Y \sim t_{n-p} \end{eqnarray}\)` ] `\(\begin{eqnarray} P(|X-\mu| > k) & = & P(|X-\mu|^2 > k^2)\\ & \leq & \frac{\mathbb{E}\left[|X-\mu|^2\right]}{k^2}\\ & \leq & \frac{\mathrm{Var}[X]}{k^2} \end{eqnarray}\)` --- name: table_kable ## Tables • `kable` The most simple table using `kable` from R package `knitr`. ```r knitr::kable(head(iris),'html') ``` <table> <thead> <tr> <th style="text-align:right;"> Sepal.Length </th> <th style="text-align:right;"> Sepal.Width </th> <th style="text-align:right;"> Petal.Length </th> <th style="text-align:right;"> Petal.Width </th> <th style="text-align:left;"> Species </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 5.1 </td> <td style="text-align:right;"> 3.5 </td> <td style="text-align:right;"> 1.4 </td> <td style="text-align:right;"> 0.2 </td> <td style="text-align:left;"> setosa </td> </tr> <tr> <td style="text-align:right;"> 4.9 </td> <td style="text-align:right;"> 3.0 </td> <td style="text-align:right;"> 1.4 </td> <td style="text-align:right;"> 0.2 </td> <td style="text-align:left;"> setosa </td> </tr> <tr> <td style="text-align:right;"> 4.7 </td> <td style="text-align:right;"> 3.2 </td> <td style="text-align:right;"> 1.3 </td> <td style="text-align:right;"> 0.2 </td> <td style="text-align:left;"> setosa </td> </tr> <tr> <td style="text-align:right;"> 4.6 </td> <td style="text-align:right;"> 3.1 </td> <td style="text-align:right;"> 1.5 </td> <td style="text-align:right;"> 0.2 </td> <td style="text-align:left;"> setosa </td> </tr> <tr> <td style="text-align:right;"> 5.0 </td> <td style="text-align:right;"> 3.6 </td> <td style="text-align:right;"> 1.4 </td> <td style="text-align:right;"> 0.2 </td> <td style="text-align:left;"> setosa </td> </tr> <tr> <td style="text-align:right;"> 5.4 </td> <td style="text-align:right;"> 3.9 </td> <td style="text-align:right;"> 1.7 </td> <td style="text-align:right;"> 0.4 </td> <td style="text-align:left;"> setosa </td> </tr> </tbody> </table> --- name: table_kableextra ## Tables • `kableExtra` More advanced table using [`kableExtra`](https://cran.r-project.org/web/packages/kableExtra/vignettes/awesome_table_in_html.html) and [`formattable`](https://cran.r-project.org/web/packages/formattable/vignettes/formattable-data-frame.html). ```r iris[c(1:4,51:53,105:108),] %>% mutate(Sepal.Length=color_bar("lightsteelblue")(Sepal.Length)) %>% mutate(Sepal.Width=color_tile("white","orange")(Sepal.Width)) %>% mutate(Species=cell_spec(Species,"html",color="white",bold=T, background=c("#8dd3c7","#fb8072","#bebada")[factor(.$Species)])) %>% kable("html",escape=F) %>% kable_styling(bootstrap_options=c("striped","hover","responsive"), full_width=F,position="left") %>% column_spec(5,width="3cm") ``` <table class="table table-striped table-hover table-responsive" style="width: auto !important; "> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:left;"> Sepal.Length </th> <th style="text-align:left;"> Sepal.Width </th> <th style="text-align:right;"> Petal.Length </th> <th style="text-align:right;"> Petal.Width </th> <th style="text-align:left;"> Species </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> 1 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 67.11%">5.1</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffa500">3.5</span> </td> <td style="text-align:right;"> 1.4 </td> <td style="text-align:right;width: 3cm; "> 0.2 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #8dd3c7 !important;">setosa</span> </td> </tr> <tr> <td style="text-align:left;"> 2 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 64.47%">4.9</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffd27f">3.0</span> </td> <td style="text-align:right;"> 1.4 </td> <td style="text-align:right;width: 3cm; "> 0.2 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #8dd3c7 !important;">setosa</span> </td> </tr> <tr> <td style="text-align:left;"> 3 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 61.84%">4.7</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffc04c">3.2</span> </td> <td style="text-align:right;"> 1.3 </td> <td style="text-align:right;width: 3cm; "> 0.2 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #8dd3c7 !important;">setosa</span> </td> </tr> <tr> <td style="text-align:left;"> 4 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 60.53%">4.6</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffc965">3.1</span> </td> <td style="text-align:right;"> 1.5 </td> <td style="text-align:right;width: 3cm; "> 0.2 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #8dd3c7 !important;">setosa</span> </td> </tr> <tr> <td style="text-align:left;"> 51 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 92.11%">7.0</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffc04c">3.2</span> </td> <td style="text-align:right;"> 4.7 </td> <td style="text-align:right;width: 3cm; "> 1.4 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #fb8072 !important;">versicolor</span> </td> </tr> <tr> <td style="text-align:left;"> 52 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 84.21%">6.4</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffc04c">3.2</span> </td> <td style="text-align:right;"> 4.5 </td> <td style="text-align:right;width: 3cm; "> 1.5 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #fb8072 !important;">versicolor</span> </td> </tr> <tr> <td style="text-align:left;"> 53 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 90.79%">6.9</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffc965">3.1</span> </td> <td style="text-align:right;"> 4.9 </td> <td style="text-align:right;width: 3cm; "> 1.5 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #fb8072 !important;">versicolor</span> </td> </tr> <tr> <td style="text-align:left;"> 105 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 85.53%">6.5</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffd27f">3.0</span> </td> <td style="text-align:right;"> 5.8 </td> <td style="text-align:right;width: 3cm; "> 2.2 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #bebada !important;">virginica</span> </td> </tr> <tr> <td style="text-align:left;"> 106 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 100.00%">7.6</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffd27f">3.0</span> </td> <td style="text-align:right;"> 6.6 </td> <td style="text-align:right;width: 3cm; "> 2.1 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #bebada !important;">virginica</span> </td> </tr> <tr> <td style="text-align:left;"> 107 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 64.47%">4.9</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffffff">2.5</span> </td> <td style="text-align:right;"> 4.5 </td> <td style="text-align:right;width: 3cm; "> 1.7 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #bebada !important;">virginica</span> </td> </tr> <tr> <td style="text-align:left;"> 108 </td> <td style="text-align:left;"> <span style="display: inline-block; direction: rtl; unicode-bidi: plaintext; border-radius: 4px; padding-right: 2px; background-color: lightsteelblue; width: 96.05%">7.3</span> </td> <td style="text-align:left;"> <span style="display: block; padding: 0 4px; border-radius: 4px; background-color: #ffdb99">2.9</span> </td> <td style="text-align:right;"> 6.3 </td> <td style="text-align:right;width: 3cm; "> 1.8 </td> <td style="text-align:left;"> <span style=" font-weight: bold; color: white !important;border-radius: 4px; padding-right: 4px; padding-left: 4px; background-color: #bebada !important;">virginica</span> </td> </tr> </tbody> </table> --- name: table_dt ## Tables • `DT` Interactive table using R package [`DT`](https://rstudio.github.io/DT/). ```r library(DT) DT::datatable(iris[1:20,],options=list(pageLength=7)) ```
--- name: plot_static_base ## Static plots • Base Plot Plots using base R are widely used and may be good enough for most situations. But they lack a consistent coding framework. ```r {par(mar=c(5,5,0,0)) plot(x=iris$Sepal.Length,y=iris$Sepal.Width, col=c("coral","steelblue","forestgreen")[iris$Species], xlab="Sepal Length",ylab="Sepal Width",pch=19) legend(x=7,y=4.47,legend=c("setosa","versicolor","virginica"), col=c("coral","steelblue","forestgreen"),pch=19)} ``` <img src="presentation-demo_files/figure-html/unnamed-chunk-14-1.png" width="360" style="display: block; margin: auto auto auto 0;" /> --- name: plot_static_ggplot ## Static plots • `ggplot2` R package [`ggplot2`](http://ggplot2.org/) is a versatile and almost complete plotting solution. ```r iris %>% ggplot(aes(x=Sepal.Length,y=Sepal.Width,col=Species))+ geom_point(size=2)+ labs(x="Sepal Length",y="Sepal Width")+ theme_bw(base_size=18) ``` <img src="presentation-demo_files/figure-html/unnamed-chunk-15-1.png" width="432" style="display: block; margin: auto auto auto 0;" /> --- name: plot_interactive_highcharter ## Interactive plots • `highcharter` R package [`highcharter`](http://jkunst.com/highcharter/) is a wrapper around javascript library [`highcharts`](https://www.highcharts.com/). ```r library(highcharter) h <- iris %>% hchart("scatter",hcaes(x="Sepal.Length",y="Sepal.Width",group="Species")) %>% hc_xAxis(title=list(text="Sepal Length"),crosshair=TRUE) %>% hc_yAxis(title=list(text="Sepal Width"),crosshair=TRUE) %>% hc_chart(zoomType="xy",inverted=FALSE) %>% hc_legend(verticalAlign="top",align="right") %>% hc_size(height=350) htmltools::tagList(list(h)) ```
--- name: plot_interactive_plotly ## Interactive plots • `plotly` R package [`plotly`](https://plot.ly/r/) provides R binding around javascript plotting library [`plotly`](https://plot.ly). ```r library(plotly) p <- iris %>% plot_ly(x=~Sepal.Length,y=~Sepal.Width,color=~Species,width=500,height=400) %>% add_markers() p ```
--- name: plot_interactive_ggplotly ## Interactive plots • `ggplotly` `plotly` also has a function called `ggplotly` which converts a static ggplot2 object into an interactive plot. ```r library(plotly) p <- ggplot(iris,aes(x=Sepal.Length,y=Sepal.Width,col=Species))+ geom_point()+ labs(x="Sepal Length",y="Sepal Width")+ theme_bw(base_size=12) plotly::ggplotly(p,width=460,height=360) ```
--- name: plot_interactive_ggiraph ## Interactive plots • `ggiraph` R package [`ggiraph`](https://github.com/davidgohel/ggiraph) converts a static ggplot2 object into an interactive plot. ```r library(ggiraph) p <- ggplot(iris,aes(x=Sepal.Length,y=Petal.Length,colour=Species))+ geom_point_interactive(aes(tooltip=paste0("<b>Petal Length:</b> ",Petal.Length,"\n<b>Sepal Length: </b>",Sepal.Length,"\n<b>Species: </b>",Species)),size=2)+ theme_bw() tooltip_css <- "background-color:#f8f9f9;padding:10px;border-style:solid;border-width:2px;border-color:#125687;border-radius:5px;" ggiraph(code=print(p),hover_css="cursor:pointer;stroke:black;fill-opacity:0.3",zoom_max=5,tooltip_extra_css=tooltip_css,tooltip_opacity=0.9,height_svg=3,width_svg=4.5,width=0.6) ```
--- name: plot_interactive_dygraphs ## Interactive time series • `dygraphs` R package [`dygraphs`](http://rstudio.github.io/dygraphs/) provides R bindings for javascript library [dygraphs](http://dygraphs.com/) for time series data. ```r library(dygraphs) lungDeaths <- cbind(ldeaths, mdeaths, fdeaths) dygraph(lungDeaths,main="Deaths from Lung Disease (UK)") %>% dyOptions(colors=c("#66C2A5","#FC8D62","#8DA0CB")) ```
--- name: plot_interactive_network ## Network graph R package `networkD3` allows the use of interactive network graphs from the [D3.js](https://d3js.org/) javascript library. ```r library(networkD3) data(MisLinks,MisNodes) forceNetwork(Links=MisLinks,Nodes=MisNodes,Source="source", Target="target",Value="value",NodeID="name", Group="group",opacity=0.4, height=350,width=600) ```
--- name: plot_interactive_leaflet ## Interactive maps • `leaflet` R package [`leaflet`](https://rstudio.github.io/leaflet/) provides R bindings for javascript mapping library; [leafletjs](http://leafletjs.com/). ```r library(leaflet) leaflet(height=350,width=650) %>% addTiles(urlTemplate='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png') %>% #addProviderTiles(providers$Esri.NatGeoWorldMap) %>% addMarkers(lat=57.639327,lng=18.288534,popup="RaukR") %>% setView(lat=57.639327,lng=18.288534,zoom=15) ```
--- name: plot_interactive_crosstalk ## Linking Plots • `crosstalk` R package [`crosstalk`](https://rstudio.github.io/crosstalk/index.html) allows crosstalk enabled plotting libraries to be linked. Through the shared 'key' variable, data points can be manipulated simultaneously on two independent plots. ```r library(crosstalk) shared_quakes <- SharedData$new(quakes[sample(nrow(quakes), 100),]) lf <- leaflet(shared_quakes,height=280) %>% addTiles(urlTemplate='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png') %>% addMarkers() py <- plot_ly(shared_quakes,x=~depth,y=~mag,size=~stations,height=280) %>% add_markers() div(div(lf,style="float:left;width:49%"),div(py,style="float:right;width:49%")) ```
--- name: tips ## General tips * Replace _assets/cover.jpg_ to change cover slide picture * Replace _assets/end.jpg_ to change end slide picture * Add custom css under YAML `css: ["default", "my-theme.css"]` * If content overflows the slide in vertical direction, this can be limited to specific height along with scroll bars using class `.limity`. Scroll bar limited containers are implemented for 100, 150, 200, 250, 300, 350, 400, 450, 500 pixels. See usage below; .small[ ```` .limity150[ ```{r} Sys.info() ``` ] ```` ] .limity150[ ``` ## sysname ## "Linux" ## release ## "5.13.0-39-generic" ## version ## "#44~20.04.1-Ubuntu SMP Thu Mar 24 16:43:35 UTC 2022" ## nodename ## "kermit" ## machine ## "x86_64" ## login ## "roy" ## user ## "roy" ## effective_user ## "roy" ``` ] * Export HTML to PDF using __pkgdown__ and chrome `pagedown::chrome_print("slides.html",output="slides.pdf")` * Check out __Xaringan__'s [wiki page](https://github.com/yihui/xaringan/wiki) and __Remarkjs__ [wiki page](https://github.com/gnab/remark/wiki) for reference --- name: end_slide class: end-slide, middle count: false # Thank you. Questions? <p>R version 4.1.0 (2021-05-18)<br><p>Platform: x86_64-conda-linux-gnu (64-bit)</p><p>OS: Ubuntu 20.04.4 LTS</p><br> Built on : <i class='fa fa-calendar' aria-hidden='true'></i> 13-Apr-2022 at <i class='fa fa-clock-o' aria-hidden='true'></i> 20:31:21 <b>2022</b> • [SciLifeLab](https://www.scilifelab.se/) • [NBIS](https://nbis.se/) • [RaukR](https://nbisweden.github.io/workshop-RaukR-2206/)