install.packages('rmarkdown')
install.packages('plotly')
24 R Markdown - Documents and Presentations in R
Today we focus on using R to make presentations - a key form of communication for data visualization. Dashboards and Documents can follow!
24.1 R Markdown
R Markdown is a package that enables an authoring framework. It enables:
- the storing and execution of R code
- the production of quality documents in formats including HTML, PDF, MS Word, dashboards, shiny apps, journal articles, websites, and more.
24.2 Prerequisites
Install and load rmarkdown
. Install plotly
too cause it is cool.
24.3 Resources
24.4 Use RMarkdown to make a Presentation to teach how to use RMarkdown to make a Presentation
Check Box for today’s .Rmd file and knit .html slide presentation.
24.5 Exercise 1 - Create a Presentation using your Visualization Assignment Code
- Open File, New File, R Markdown…
- Select Presentation
- Add your name and a title
- Check out the template components
- Edit the introduction to include a sentence about the visualization you created for your last assignment.
- Add each of the four bullet points to the Slide with Bullets
- Replace the code chunks with the table and plot with the
R
code you used to generate your visualization, including the libraries, data download, and tidying steps. See the example code chunk below. - Press the Knit button to generate a rendered HTML presentation.
library(sf)
library(leaflet)
URL.path <- 'https://raw.githubusercontent.com/RadicalResearchLLC/EDVcourse/main/CalEJ4/CalEJ.geoJSON'
SoCalEJ <- st_read(URL.path) %>%
st_transform("+proj=longlat +ellps=WGS84 +datum=WGS84")
palDPM <- colorNumeric(palette = 'YlOrBr', domain = SoCalEJ$DieselPM_P)
leaflet(data = SoCalEJ) %>%
addTiles() %>%
setView(lat = 33.8, lng = -117.60, zoom = 9) %>%
addPolygons(stroke = FALSE,
fillColor = ~palDPM(DieselPM_P),
fillOpacity = 0.5) %>%
addLegend(pal = palDPM,
title = 'Diesel PM (%)',
values = ~DieselPM_P)