Tidy Data Rule #2: Every Row is an Observation
This lesson is called Tidy Data Rule #2: Every Row is an Observation, part of the R in 3 Months (Fall 2026) course. This lesson is called Tidy Data Rule #2: Every Row is an Observation, part of the R in 3 Months (Fall 2026) course.
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.
Loading transcript...
Your Turn
Run the following code to view the built-in gss_cat data frame.
library(tidyverse)
gss_cat |>
view()
Then, write code to count the number of unique responses in the partyid variable.
You’ll need to use the separate_longer_delim() and count() functions to do this.
Learn More
This lesson from the R for Social Scientists course materials covers separate_longer_delim().
Have any questions? Put them below and we will help you out!
Course Content
143 Lessons
You need to be signed-in to comment on this post. Login.
Mallik Janthak • November 1, 2026
In gss_cats, partyid is shown to be of the type
<fct>. Can you refresh my memory on this type and where it is used?Gracielle Higino Coach • November 3, 2026
Hi Mallik! Factors are categorical variables that can be ordered by a defined order other than alphabetical or numerical. We have a special lesson about this here. We use factors pretty much everytime we need a categorical variable that has an intrinsic order of values (like "big", "medium" and "small"), instead of a character variable (you can think of those as plain text variables that are not ordered, like species names). I hope this helps! We'll have a moment to discuss that in the live session this week.
Lilly Yu • November 5, 2026
I noticed that in the solution, there is a select(partyid) |>, whereas the code I modeled mine off in the video omitted this. I got the same result using both code. What does select(partidyid) do here exactly?
Gracielle Higino Coach • November 5, 2026
Hi Lilly! You can get the same result without the select() in this case. It's here for clarity and pedagogical purposes only, just so we focus on this variable specifically. As always, there are many ways to do the same thing in R!