R Markdown and Interactive Dashboards Workshop - rstudio::conf 2020

R Markdown and Interactive Dashboards Workshop

1/27/20—1/28/20
9:00 AM-5:00 PM
2 Day Workshop

Carl Howe
Director of Education
RStudio

Yihui Xie
Software Engineer and Data Scientist
RStudio


This 2-day introductory workshop will teach students the fundamentals how to create R Markdown scripts for reports and interactive applications. Attendees will learn how to:

  • Design R Markdown for reproducibility and reuse.
  • Craft their own R Markdown reports.
  • Parameterize R Markdown content for personalized report generation
  • Publish R Markdown content to other servers such as RStudio Connect and RPubs.
  • Add flexdashboard interactive elements and pages to R Markdown documents
  • Combine htmlwidgets with static content to create dynamic dashboards
  • How to add Shiny interactivity to your dashboard.
  • Structure dashboards to visualize data from real-time Web sources
  • Design interactive applications for best performance.

Students will gain experience constructing several reports and dashboards from data sets provided to the class. Attendees will also participate in a master class with Yihui Xie, the creator and co-author of R Markdown, to learn the details behind how R Markdown actually works and to get answers to their thorniest R Markdown questions.

This class is appropriate for attendees who want to:

  1. Create reproducible data analyses and reports that can be shared with a large audience.
  2. Craft interactive dashboards for others to understand their data and analyses.
  3. Build stand-alone Web applications that allow users to visually explore data and find insights of their own.

While no experience with R is required for our work with R Markdown, attendees will need knowledge of R and some experience with the tidyverse to build Shiny Web applications.

5 Likes

Dear workshop attendee:

Thank you for registering for R Markdown and Interactive Dashboards! Yihui and I are looking forward to sharing two fun-filled days of R Markdown and Interactive Dashboards with you, and we hope you are too.

We’d like to make the most of our time together in person, so we recommend spending a bit of time preparing for the workshop. You should already have received an email with general recommendations such as bringing your laptop and power cord (if you didn’t, the document is here), so we’ll focus here on recommendations that are specific to R Markdown and Interactive Dashboards.

Prior to the beginning of the workshop on January 27

This workshop is taught using rstudio.cloud, a cloud-based learning environment. That means that most of your work will be done online using a browser instead of in an IDE on your laptop. With that said, you’ll be able to get started more quickly on the first day of the workshop if you:

  • Create an account on rstudio.cloud. All you need to create an account on rstudio.cloud is to visit https://rstudio.cloud, enter a valid email address, and hit “Sign up”. Alternatively you can log in with an existing Google or Github account.
  • Download R software onto your laptop as a backup. While this step isn’t strictly necessary, should rstudio.cloud go down during the class, you’ll want to be able to continue with the course using a local version of R.
    • A recent version of R (>=3.6.0), which is available for free at https://cloud.r-project.org/
    • A recent version of RStudio Desktop (>=1.2), available for free (RStudio Desktop Open Source License)
    • A modern browser. Supported browsers include:
      • Microsoft Edge
      • Internet Explorer 11+
      • Chrome
      • Safari
      • Firefox
    • The following R packages. You can do this all at once by typing:
      install.packages(c("geonames", "tidyverse", "magrittr", "rmarkdown", "flexdashboard", "leaflet", "babynames", "tufte", "rticles", "shiny", "DT", "reticulate", "revealjs", "plotly"))
      remotes::install_github("noamross/redoc")
      
  • DO NOT create your workshop workspace yet. While it may be tempting to get ready for the workshop by looking around for the materials on github and downloading them, I encourage you to wait until Monday morning. Any materials you download prior to then won’t be final and may not provide correct information.

On Monday, January 27, the day your workshop begins

Our workshop will be held in the Continental Ballroom Rooms 7-9 on the Ballroom level of the Hilton Union Square Hotel. The workshop will begin promptly at 9 am.

  • Bring your tablet or mobile phone in addition to your laptop. Many students find it useful to display slides or other ancillary materials on a second screen while working in RStudio.cloud on their computer. If you have a small Chromebook, tablet, or large mobile phone, feel free to bring that to the workshop -- you may find it helpful.
  • Get registered in the Yosemite Room, Ballroom Level. Getting more than 1,300 people registered and badged is going to take time. You can avoid waiting in long lines by arriving early, getting some coffee, and finding the room. Registration starts at 6:30 am. Better yet, if you are local to San Francisco, come register on Sunday night between 4 and 7 pm.
  • Find a seat and power in Continental Ballroom Rooms 7-9 on the same level as Yosemite. You will need your conference badge to gain admission to the workshop in Continental Ballroom Rooms 7-9. Find yourself a comfy seat at a table where you can see the instructor and the screens.
  • Check to make sure you can get to rstudio.cloud. Once you’ve joined the WiFi network in the room, try to access rstudio.cloud. You should get a login screen. If you haven’t created an rstudio.cloud account yet, do so now; you only need an email address or a Google or Github account to log in.
  • Wear layers. We’ll do our best to keep the workshop rooms comfortable, but we know that no matter what temperature is set, some will find the room temperatures too hot or too cold. We recommend wearing light clothes in case the room is warm and bringing a sweater or jacket in case it is too cold.

Join the community after your workshop

Learning doesn’t end when the workshops finish. Open bar receptions between 5:30 and 7:30 on both Monday and Tuesday evenings will give you a chance to talk about what you’ve learned in a less formal environment and to network with instructors and students from other workshops.

We look forward to seeing you in San Francisco!

Carl Howe, Director of Education
Rstudio

1 Like

You forgot one parenthesis at the end.

install.packages(c("geonames", "tidyverse", "magrittr", "rmarkdown",
 "flexdashboard", "leaflet", "babynames", "tufte", "rticles", "shiny",
 "DT", "reticulate", "revealjs", "plotly"))
1 Like

I'm getting an error message for the package from Github.

> remotes::install_github("noamross/redoc")
Error: Failed to install 'unknown package' from GitHub:
  HTTP error 401.
  Bad credentials

  Rate limit remaining: 59/60
  Rate limit reset at: 2020-01-26 06:56:54 UTC

Steps to resolve error:

  1. Login to github.com
  2. Create a new personal access token (Settings > Developer settings > Personal access tokens)
  3. Copy the token
  4. In RStudio, run usethis::edit_r_environ()
  5. Store the token in R, save, and restart R.
GITHUB_PAT=xxxx
  1. Run remotes::install_github("noamross/redoc")
1 Like

Could you talk about labeling figures and tables (e.g., Figure 1-1, Figure 1-2, Table 1, Table 2, Table 3)? Assume the figures and tables were generated inside an R chunk (e.g., plot(mtcars) and knitr::kable(df).)

And how we can reference the figure and table labels in the narratives (e.g., "Please refer to Table 1 for a summary of model statistics.")?

Sure, I'll talk about it: https://slides.yihui.org/2020-rstudio-conf-rmarkdown-recipes.html#34

When I open 55-movies5.Rmd and click Run Document, the shiny app renders correctly.

However, when I close the preview window, and click Run Document again, the shiny app renders white rectangles.

Adding a space to 55-movies5.Rmd and click Run Document solves the issue, but this seems like a hack.

What are your thoughts on breaking a very long Rmd file into multiple smaller Rmd files and then using a "parent" Rmd to call each child Rmd. Would the second child Rmd being able to see the environment objects from the first child Rmd?

Flexdashboard is limited if we might want a more complex dashboard layout. Are there other output types that can support more custom layout grids?

When using blogdown I get nice compact .md files as output, which Netlify takes and creates the html file on demand. When using htmlwidgets in my report (e.g., plotly graphics) I have only been able to use html files, and they are quite large. Is there any way to produce more efficient files/workflow for html reports both with and without blogdown?

Not that I know of. I believe that the bloat comes from the Javascript content that creates the interactivity. If you remove the bloat, you remove the interactivity.

-Carl

The only toolchain I know to create arbitrary UIs is Shiny, and you can build dashboards using it using the shinydashboard package.

-Carl

Thanks Carl. Is there a way to do either of these things?

  1. Produce "bloated" .md files (that are still a little smaller than .html files?
  2. Have the .html reports call in a good portion of the javascript remotely instead of putting the javascript inline?

Unfortunately neither is possible.

  1. The primary "bloated" thing is not .html compared to .md, but the giant JSON objects generated by plotly. Even if you use .md, you still get these JSON objects. There is no way to reduce their size, especially when your data is large (because the full data has to be serialized into JSON).

  2. That's a good idea, and is also what I have wished HTML widgets could do for years. Sometimes I also hate storing JS libraries locally, which has obvious advantages (e.g. stable, works offline, etc.), but sometimes I do prefer lightweight HTML files and don't mind pulling JS libraries over the network. That said, it is currently still not possible. The whole HTML widgets framework is strongly biased towards rendering widgets inline and locally.

At the moment, I can only suggest you close your eyes and not look at the gigantic .html files. In other words, write in R Markdown, ignore everything else, and then git commit everything. :laughing:

2 Likes

Thanks Yihui. I hope that in the future remote JS will be possible.

I tried to log into the R conf workspace for this workshop from our cloud accounts, but found that the workspace was not available. Was the workspace discontinued after the workshop? I still have the R cloud account, but the workspace we used for the conference is not available like it was at the workshop. Just wanted to see if this was expected. I know it is available on git hub also. Thank you!

I just tried logging into rstd.io/RMAID and it worked fine for me as an anonymous user. Can you send the URL you are using?

Thanks,
-C