tallying multiple observations in an entire data frame

If you just want a total count of each label, you can use unnest_longer and a grouped count:

# using @DPH's example data
library(dplyr)
library(tidyr)

df %>%
  mutate(across(PL, strsplit, ";")) %>%
  unnest_longer(PL) %>%
  group_by(PL) %>%
  count()

# A tibble: 6 x 2
# Groups:   PL [6]
  PL             n
  <chr>      <int>
1 HTML/CSS       2
2 Java           1
3 JavaScript     2
4 Python         1
5 R              3
6 SQL            2

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top