R: Group by values in a column and count each value
In tidyverse
you may reshape the data to long format, count
and reshape to wide format.
library(dplyr)
library(tidyr)
df1 %>%
pivot_longer(cols = -student) %>%
count(name, value) %>%
pivot_wider(names_from = name, values_from = n)
However, I think it is easier in base R in this case -
sapply(df1[-1], table)
# budget resume cover
#completed 1 3 1
#in progress 2 1 2
#not started 3 2 3