Get access to all lessons in this course.
-
Advanced Data Wrangling
- Downloading and Importing Data
- Overview of Tidy Data
- Tidy Data Rule #1: Every Column is a Variable
- Tidy Data Rule #3: Every Cell is a Single Value
- Tidy Data Rule #2: Every Row is an Observation
- Changing Variable Types
- Dealing with Missing Data
- Advanced Summarizing
- Binding Data Frames
- Functions
- Data Merging
- Exporting Data
- Bring It All Together (Advanced Data Wrangling)
-
Advanced Data Visualization
- Best Practices in Data Visualization
- Tidy Data
- Pipe Data into ggplot
- Reorder Plots to Highlight Findings
- Line Charts
- Use Color to Highlight Findings
- Declutter
- Add Descriptive Labels to Your Plots
- Use Titles to Highlight Findings
- Use Annotations to Explain
- Tweak Spacing
- Create a Custom Theme
- Customize Your Fonts
- Try New Plot Types
- Bring it All Together (Advanced Data Visualization)
-
Quarto
- Advanced Markdown
- Advanced YAML and Code Chunk Options
- Tables
- Inline R Code
- Making Your Reports Shine: Word Edition
- Making Your Reports Shine: PDF Edition
- Making Your Reports Shine: HTML Edition
- Presentations
- Dashboards
- Websites
- Publishing Your Work
- Quarto Extensions
- Parameterized Reporting, Part 1
- Parameterized Reporting, Part 2
- Parameterized Reporting, Part 3
- Wrapping up Going Deeper with R
Going Deeper with R
Advanced YAML
This lesson is locked
This lesson is called Advanced YAML, part of the Going Deeper with R course. This lesson is called Advanced YAML, part of the Going Deeper with R 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
Add a table of contents and make it floating
Adjust default figure height, width, and captions
Add a parameter to the YAML and use it in the body of your report to dynamically create a table of the top 10 districts by various race/ethnicity categories
Learn More
As I was making this course, I was confused about when you would define things like figure height and width in the YAML versus in the setup code chunk. Yihui Xie, developer of RMarkdown, helpfully laid out the differences for me in this RStudio Community thread.
I mention parameterized reporting in the video. This is the idea of making multiple reports at once. The Urban Institute has a nice walkthrough of how this works.
If you're looking for more YAML options, check out RMarkdown: The Definitive Guide as well as the ymlthis
package.
You need to be signed-in to comment on this post. Login.
Abby Isaacson
May 26, 2021
FYI I got this error AFTER I had successfully changed the variable names, so I updated: columns = vars(...)` has been deprecated in gt 0.3.0:
columns = c(...)
insteadcolumns = vars(...)
has been deprecated in gt 0.3.0:columns = c(...)
insteadAbby Isaacson
May 26, 2021
Also, any ideas why my test caption doesn't show up? YAML: output: html_document: toc: TRUE toc_depth: 2 toc_float: TRUE fig_width: 8 fig_height: 10 fig_caption: TRUE
CODE:
Matt M
December 12, 2021
the floating TOC in this course and elsewhere (e.g., https://bookdown.org/yihui/rmarkdown/html-document.html) keep the location within the TOC when I click to a different portion. But I’ve noticed that the TOC for R Graphics Cookbook always goes back to the top upon click (which I find annoying). What setting dictates whether the TOC “stays put” vs “returns to top”?
Elan Sykes
December 31, 2021
How do I know where I can put params$parameter_of_choice into the report and have it knit correctly? I tried to put it into the cols_label() function within quotes and it just showed up as "params$race_ethnicity" in the html doc: enrollment_race_ethnicity_with_percentages %>% filter(race_ethnicity == params$race_ethnicity) %>% filter(schoolyear == "2018_2019") %>% slice_max(percent_ethnicity, n = 10) %>% select(district, percent_ethnicity) %>% gt() %>% cols_label( district = "District", percent_ethnicity = "2018-2019 params$race_ethnicity Population Share" )
Sara Cifuentes
June 9, 2022
Hi, Although I have included this information in my YAML: output: html_document: toc: TRUE toc_depth: 2 toc_float: TRUE
I can't see the table of contents. Should I activate any specific library? Thank you in advance.
Emma S
December 24, 2022
How could you dynamically pick the district with the most growth for the highlight_district data frame in the ggplot chart? We previously explicitly typed "Douglas ESD" as the one with the most growth for the Hispanic/Latino population then highlighted it in orange in the chart. Is there a way to automatically highlight the district with the most growth, based on the race_ethnicity parameter?