Get access to all lessons in this course.
-
Advanced Data Wrangling and Analysis
- Overview
- Importing Data
- Tidy Data
- Reshaping Data
- Dealing with Missing Data
- Changing Variable Types
- Advanced Variable Creation
- Advanced Summarizing
- Binding Data Frames
- Functions
- Merging Data
- Renaming Variables
- Quick Interlude to Reorganize our Code
- Exporting Data
-
Advanced Data Visualization
- Data Visualization Best Practices
- Tidy Data
- Pipe Data Into ggplot
- Reorder Plots to Highlight Findings
- Line Charts
- Use Color to Highlight Findings
- Declutter
- Use the scales Package for Nicely Formatted Values
- Use Direct Labeling
- Use Axis Text Wisely
- Use Titles to Highlight Findings
- Use Color in Titles to Highlight Findings
- Use Annotations to Explain
- Tweak Spacing
- Customize Your Theme
- Customize Your Fonts
- Try New Plot Types
-
Advanced RMarkdown
- Advanced Markdown Text Formatting
- Tables
- Advanced YAML
- Inline R Code
- Making Your Reports Shine: Word Edition
- Making Your Reports Shine: HTML Edition
- Making Your Reports Shine: PDF Edition
- Presentations
- Dashboards
- Other Formats
-
Wrapping Up
- You Did It!
Going Deeper with R (v1)
Tables
This lesson is locked
This lesson is called Tables, part of the Going Deeper with R (v1) course. This lesson is called Tables, part of the Going Deeper with R (v1) 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
Change the default data frame printing method to use kable
Choose one of the table packages and make an attractive table that shows the top 10 districts with the highest percentage of Hispanic/Latino students (hint: use the
slice_max()
function to get the top 10 and thefmt_percent()
function if you’re usinggt
or thepercent()
function otherwise to display the percentage of Hispanic/Latino students in each)
Please note that in order to use the slice_max()
function, you need to have dplyr
1.0 or greater installed.
Learn More
If you want to read more about df_print options, you can find that here.
If you’re looking for an overview of all of the table packages discussed in this lesson, check out this comprehensive blog post I wrote.
That blog post includes links to some great tutorials on the various packages. Some additional tutorials have come out since then, especially on the gt
package. See, for example, tutorials by:
In case it’s not already clear, the gt
package is really popular, in large part because of this endorsement from Hadley Wickham.
gt = grammar of tables. It aims to do for tables what ggplot2 did for graphics. It’s still early days and tables are surprisingly complicated, but this is a very exciting package by a skilled developer! #rstats https://t.co/138FrCy5th
— Hadley Wickham (@hadleywickham) April 8, 2020
You need to be signed-in to comment on this post. Login.
Abby Isaacson
May 25, 2021
I'm not sure at what step my years got off, but my enrollment_by_race_ethnicity dataset has always displayed '2018-2019' for one year and '2017-18' format for the other. I tried using col_labels to rename a numeric variable but it didn't work. Can I rename in gt, or do I have to go back to the dataset?
Jessica Sickler
May 26, 2021
Is it possible to print a formatted table as an image to insert in report or document outside of R?
Jody Oconnor
May 29, 2021
I'd like to create the 'your turn' table using flextable, but I'm not having much luck with the syntax. Could you post example code using flextable instead of gt please? Thanks!
Atlang Mompe
June 25, 2021
Hi David, it seems that I cannot load the gt library - I have tried to follow your video? Please advise. > library(gt) Error in library(gt) : there is no package called ‘gt’
Andrew Paquin
May 29, 2023
Hi David, As I worked through this stuff today, I received several warnings that "vars" has been deprecated and that I should used c() instead. Has vars gone the way of the pet rock? Is there a hard date after which it simple won't work at all?