Skip to content
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Learn More

The sample dashboard shown in the video is here. It is produced with the flexdashboard package.

R for Data Science can be found here. I showed chapter 3 (on data visualization) in the video. The corresponding RMarkdown document is on GitHub here.

Shiny is the package for making interactive web apps. The bus dashboard example is here.

The RMarkdown document that I used to make the slides for this course is here (the slides themselves are here). I made the slides using the xaringan package.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

JULIO VERA DE LEON

JULIO VERA DE LEON

March 19, 2022

Hi David, regarding Rmarkdown and Shiny, I understood from your video that it is possible to create a Shiny web app from a Rmarkdown file. Am I right?

Charlie Hadley

Charlie Hadley

March 21, 2022

Hi Julio! It's certainly possible to use {shiny} within an RMarkdown document, here's some example code:

---
title: "Untitled"
output: html_document
runtime: shiny
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(shiny)

R Markdown

selectInput("selected_vore",
            label = "Select a diet type",
            choices = unique(msleep$vore))
renderPlot(msleep %>% 
  filter(vore == input$selected_vore) %>% 
  ggplot(aes(x = sleep_total,
             y = sleep_rem)) +
  geom_point() +
  labs(title = str_glue("Sleep behaviours of {input$selected_vore} animals")))

I sometimes do this when I have a small number of shiny things to add to an RMarkdown document. But at some point it becomes easier for me to build a shiny app normally.

Hope this helps. There's also <a href="https://bookdown.org/yihui/rmarkdown/shiny-documents.html" rel="nofollow ugc">some documentation available here</a>. Cheers, Charlotte

JULIO VERA DE LEON

JULIO VERA DE LEON

March 21, 2022

Yes! It helped a lot, thank you.

Saw in your video sometimes using spaces between = and FALSE i.e = FALSE and sometimes not i.e. =FALSE . My code worked with include=FALSE (no space) and warning = FALSE and message = FALSE (spaces) Are both acceptable?

Charlie Hadley

Charlie Hadley

September 23, 2022

Hi Jeph!

We're really lucky in the R language that spaces don't really matter, which means we can use either some_arg=FALSE or some_arg = FALSE.

It's good to have standardised coding styles so that there can be consistency on projects. We recommend the tidyverse style guide which has a specific section on spacing - https://style.tidyverse.org/syntax.html?q=spaces#spacing - but please note that page uses very technical language that isn't necessary to understand right now.

Thanks,

Charlie

Abdulkadir Lokhandvala

Abdulkadir Lokhandvala

April 4, 2023

Hi David, I work with SAS and create lots of macros [equivalent to functions in R] for wider community of programmers in out org. One of the way I can utilize R Markdown is to create the documentation of SAS Macros. I need the help on two things:

  1. How can I change the color of certain words in syntax.? So within R Markdown, I insert SAS syntax and some of Keywords should be highlighted in Blue.
  2. I also want to create bookmarks in html document, so I can insert multiple documentation at the same time

David Keyes

David Keyes

April 4, 2023

To change colors, it depends on which output format you're using. Here's some good info that details how to do this in HTML or with LaTeX.

On creating bookmarks, do you mean like creating a table of contents? If so, this will help. If you're thinking of something else, let me know and I'll give you some ideas!