On-Demand Tutorial

Three Things You Didn’t Know You Could Do in R

In this introductory workshop – the first in the R series – review some capabilities of R that you may not know about to uplevel your next project. First, review some basic terms in R (R Foundation, 2025) and RStudio (Posit team, 2025) for some context. Then, next dive into three tasks you can do directly using R that might surprise you: scrape openly accessible data, create sophisticated, reproducible reports, and build slide decks.

Follow along by downloading the HTML file from out GitHub page.

Before You Begin: A Few R Basics

R is a free, open-source programming language commonly used for statistics, data analysis, and visualization. In this workshop, we work in RStudio, an integrated development environment from Posit that makes writing and running R code easier.

A few concepts that will be helpful as you follow along:

  • Scripts and projects: You’ll typically work in R scripts, R Markdown, or Quarto documents, all saved within a working directory on your computer.
  • Objects and data frames: Data in R is often stored in data frames, which function similarly to Excel spreadsheets.
  • Functions and packages: R functions perform specific tasks, and packages bundle related functions together.

If you’re comfortable working with spreadsheets and basic formulas, R is often more approachable than it first appears.

1. Scrape Openly Accessible Data from the Web

One powerful capability of R is the ability to pull in real-time, publicly available data directly from websites, a process known as web scraping.

In the workshop, we demonstrate how to use the rvest and polite packages to scrape a Wikipedia table containing GDP and population data for the top 50 U.S. metropolitan statistical areas. This type of data can serve as valuable context for many business and research questions.

The basic workflow looks like this:

  1. Check a website’s Terms of Use and scraping policies.
  2. Use polite to introduce your request responsibly.
  3. Use rvest to extract tables or page elements.
  4. Clean and convert the scraped data into usable numeric formats.

Because scraped data updates automatically as source pages change, this approach allows you to keep analyses current without manual data collection. Always be sure to review and follow a site’s Terms of Use.

2. Create Interactive, Reproducible Reports

R also makes it easy to create polished, interactive reports using R Markdown or Quarto. These tools allow you to combine text, tables, and visualizations in a single document that can be rendered as HTML, PDF, or Word files.

In the video example, we walk through generating an HTML report that includes descriptive statistics tables and static and interactive data visualizations. R reports automatically update outputs with new data or code.

Key elements of these reports include:

  • Metadata at the top of the file to control titles, authors, dates, and output formats
  • Markdown text for headers, lists, and notes
  • Code chunks that run analyses and generate visuals directly in the document

With a single click, your report renders into a clean, shareable format, reducing errors and making report creation fast and reproducible.

3. Automatically Generate PowerPoint Deck

Finally, R can create PowerPoint presentations directly from your code. You can create slides using Quarto (included in a future workshop) or using R packages such as officer.

Using the officer package, you can:

  • Create a new slide deck (or apply an existing template)
  • Add slides programmatically
  • Insert tables and plots generated in R
  • Save an updated presentation file with one line of code

This approach ensures that slides always reflect the latest data and eliminates the need to manually copy charts into PowerPoint. It’s especially useful for recurring presentations that need frequent updates.

By Ginny Ulichney, Research Analytics, Wharton AI & Analytics Initiative

Pro tips

This workshop is meant to provide a basic introduction to a few helpful skills, but is just a taste of the many things you can do in R. For more background on skills covered in this workshop, check out the included additional resources.

To dive deeper into select R topics, check out other WAIAI R workshop series videos:

  • Basic text analysis: Learn about basic text cleaning and analysis functions in R to get an overview and observational insights from messy text data.
  • Interactive data visualizations: Enhance your next project with customizable, interactive data visualizations geared towards audience understanding.
  • Data dashboards: Explore how you can build your next data dashboard directly in R following dashboard principles to track key metrics and trends in a clear, modifiable format.