Skip to content
Ally is live! Learn to use AI with R today.
R for the Rest of Us Logo

Fundamentals of R

Bring it All Together (Data Wrangling)

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.

View code shown in video
# Load Packages -----------------------------------------------------------

library(tidyverse)
library(janitor)

# Import Data -------------------------------------------------------------

# Data from https://github.com/rstudio/r-community-survey

survey_data <- read_tsv("2020-combined-survey-final.tsv") |>
  clean_names()

survey_data |>
  select(contains("enjoy"))

avg_r_enjoyment <-
  survey_data |>
  drop_na(qr_enjoyment) |>
  group_by(qcountry) |>
  summarize(
    avg_enjoyment = mean(qr_enjoyment),
    number_of_responses = n()
  ) |>
  filter(number_of_responses >= 10) |>
  arrange(desc(avg_enjoyment))

Learn More

The data used in this lesson comes from the R Community Survey conducted in 2020.

To learn more about the Air code formatter, check out its docs.

If you want to see a visual representation of how the various dplyr functions you've learned in this section of the course work, check out the Tidy Data Tutor website.

A less visual, though equally useful, approach is the tidylog package. It gives you feedback on each step of your pipeline, showing the data was transformed.

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

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

Al-Afroza Sultana

Al-Afroza Sultana • April 10, 2026

Hi, I am facing difficulty in installing janitor. After installing the library(tidyverse) in a new window, when I run the code library(janitor), it says- there is no package called ‘janitor’. Please let me know how to fix it. Thanks

Gracielle Higino

Gracielle Higino Coach • April 13, 2026

The janitor package is not part of the tidyverse, it should be installed separately. Run the following and let us know if it solves the problem:

install.packages("janitor")
library(janitor)
Al-Afroza Sultana

Al-Afroza Sultana • April 15, 2026

Yes, it worked. I didn't realize it's a different package. Thank you, Gracielle!

Lilly Yu

Lilly Yu • October 1, 2026

Ctrl + \ didn't work for me to turn a line into a comment, but ctrl + shift + c did. Is there a reason the former doesn't work and is it important to get it to work?

Gracielle Higino

Gracielle Higino Coach • October 1, 2026

Hi Lilly! ctrl + shift + c is the shortcut we use in RStudio, and there's an option for Positron to use that instead of ctrl + /

Check what's on your configurations for RStudio Keybindings (you can click here). There's an option there to allow Positron to use the same shortcuts as RStudio. If the box is checked, that's why ctrl + / is not working for you.

It doesn't really matter which one you use. Pick the one you feel most comfortable using!

Lilly Yu

Lilly Yu • October 1, 2026

Thank you! Turns out I was hitting the regular , not backslash!

New from Ally Chat, extension, or terminal: where to work with AI