Skip to content
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

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.

Your Turn

Convert your report to bookdown

Learn More

If you want to learn more about bookdown, there is a book all about it (and yes, it is made with bookdown).

To make a website using the distill package, check out this page on the distill website. If you want to see a distill website in action, Tom Mock’s blog is made with it.

The best place to start with blogdown is the book blogdown: Creating Websites with R Markdown. One of the authors is Alison Hill, who I mentioned in the video has a lot of great material on blogdown. I’d suggest starting with her extensive blog post Up & Running with blogdown.

Dan Quintana also has a bunch of materials on getting started with blogdown, shown in this Twitter thread.

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

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

Atlang Mompe

Atlang Mompe

June 28, 2021

Hi David, this is my code below for this last exercise, can I ask why I did not get a book format based on my code:

title: "Report on Diversity in Oregon School" author: "Atlang Mompe" date: "r Sys.Date()" params: race_ethnicity_category: "Hispanic/Latino" output: bookdown::gitbook

knitr::opts_chunk$set(echo = FALSE,
                      message = FALSE,
                      warning = FALSE,
                      cache = TRUE)
#Load the libraries
library(tidyverse)
library(hrbrthemes)
library(scales)
library(ggtext)
library(extrafont)
loadfonts()
library(janitor)
library(ggalt)
library(dplyr)
library(gt)
library(pagedown)
#Load the data
enrollment_by_race_ethnicity % 
  filter(district == "Beaverton SD 48J") %>% 
  filter(year == "2018-2019") %>% 
  ggplot(aes(x = percent_of_total_at_school,
             y = race_ethnicity)) +
  geom_col()
# fct_reorder() solution

enrollment_by_race_ethnicity %>% 
  filter(district == "Beaverton SD 48J") %>% 
  filter(year == "2018-2019") %>% 
  mutate(race_ethnicity = fct_reorder(race_ethnicity, percent_of_total_at_school)) %>% 
  ggplot(aes(x = percent_of_total_at_school,
             y = race_ethnicity)) +
  geom_col()
#How to create a line chart with geom points
#Always check the space between the function and brackets

enrollment_by_race_ethnicity %>% 
  filter(race_ethnicity == params$race_ethnicity_category) %>% 
  ggplot(aes(x = year,
             y = percent_of_total_at_school,
             group = district)) +
  geom_point() +
  geom_line()

highlight_district % 
  filter(race_ethnicity == "Hispanic/Latino") %>% 
  filter(district == "Douglas ESD")

#Use color to highlight findings

highlight_district % 
	  filter(race_ethnicity == "Hispanic/Latino") %>% 
	  filter(district == "Douglas ESD")

	enrollment_by_race_ethnicity %>% 
	  filter(race_ethnicity == "Hispanic/Latino") %>% 
	  ggplot(aes(x = year,
	             y = percent_of_total_at_school,
	             group = district)) +
	  geom_line(color = "lightgray",
	            alpha = 0.5) +
	  geom_line(data = highlight_district,
	            inherit.aes = TRUE,
	            color = "blue")
#Decluttering a graph

enrollment_by_race_ethnicity %>