Author Archives: Patrick

TidyX 92: RMarkdown – Multiple Tab Reports

A problem that we often run into when building reports is that the amount of data can make the report itself rather long. RMarkdown can assist us in streamlining the data sharing process by creating an clickable Table of Contents at the top of the report and by adding tabs within the report that are designated to specific data or research questions. Therefore, this week, Ellis Hughes and I discuss how you can create multiple tabs within your RMarkdown report.

To watch our screen cast, CLICK HERE.

To access our code, CLICK HERE.

TidyX 91: RMarkdown – Code Chunks & Figure Options

Picking up where we left off last week, Ellis Hughes and I dive into controlling code chunks and figure options within your RMarkdown reports.

We cover:

1) How to show or hide your code in the report
2) How to show or hide the output of your code in a report
3) How to show code without having R run it in the report
4) Setting figure height, width, and alignment
5) Setting a figure caption

The first RMarkdown file covers the basics <CLICK HERE>

The second RMarkdown walks through a more nuanced example, where we scrape data from basketball-reference.com and create a {ggplot2} plot of Team Offensive and Defensive Rebounds <CLICK HERE>

To watch the screen cast, CLICK HERE.

TidyX 90: RMarkdown Guide – Formatting

This week, Ellis Hughes and I begin a new series on RMarkdown. We will be going over the functionality of RMarkdown files and how you can quickly and easily build reports.

This first episode covers some of the basics of RMarkdown files:

  • Formatting text
  • Creating headers
  • Creating bulleted or numbered lists
  • Running code
  • Writing statistical equations
  • Adding links, image files, and figures into the report

To watch our screen cast, CLICK HERE.

To access our code, CLICK HERE.

TidyX 89: Constructing Tables for Research Publication in R

This week, Ellis Hughes and I delve into our mailbag to answer a question posed to us inquiring how we would go about creating tables for research publication in R. Most of the time it seems that people will get their model outputs and transpose them into Excel to build a table. But, in R you can go directly from the model output straight to a nice table that meets that journal’s requirements.

In this episode, we build a regression model and use {broom} to tidy the model outputs into a clean data frame. When then take that output and walk through different ways of using {gt} to customize your table for publication. We wrap up by covering how to build a plot of the interquartile range and annotate that plot to provide more context using {ggplot2}.

To watch our screen cast, CLICK HERE.

To access our code, CLICK HERE.

Tidymodels model fitting template

We recently completed a 10 episode series on the Tidy Explained screen cast about building models within the {tidymodels} framework of R.

To tie it the series together I put together an RMarkdown file that walks through the model fitting process in {tidymodels}. The RMarkdown template provides a step-by-step process that one can take when building {tidymodels} on their own data.

If you knit the RMarkdown template, you will get an html report that covers the basics of:

  • Splitting data into training, testing, and cross validation sets
  • Specifying models
  • Pre-processing with model recipes
  • Setting up workflows and workflowsets
  • Fitting models and parameter tuning
  • Evaluating model outputs
  • Making predictions on test data
  • Saving the model workflow for future model deployment
  • Loading the saved model workflow and deploying it on a new data set

To access the template, go to my GITHUB page.

Below are the 10 {tidymodels} episodes we did on Tidy Explained if you’d like to see the processes performed in real time:

TidyX 77: Intro to tidymodels
TidyX 78: Splits & Recipes
TidyX 79: Cross-Validation & Model Metrics
TidyX 80: Tuning Decision Trees
TidyX 81: Logistic Regression
TidyX 82: Random Forest Classifier
TidyX 83: Naive Bayes Classifier
TidyX 84: Workflowsets
TidyX 85: Workflowsets & Parameter Tuning
TIdyX 86: Tidymodels interview with Julia Silge