I want to get the group-wise count of numbers.
In the below data, there is 0,2,4,5,6. I would like to get the count of these scores gender-wise. Like, for males, how many zeros, twos and fours appear.
library(tidyverse)
tibble::tribble(
~child_id, ~gender, ~q1_score,
"PEN001", "male", 0L,
"PEN002", "male", 0L,
"PEN003", "female", 2L,
"PEN004", "female", 4L,
"PEN005", "male", 2L,
"PEN006", "male", 6L,
"PEN007", "female", 6L,
"PEN008", "male", 5L
)
#> # A tibble: 8 x 3
#> child_id gender q1_score
#> <chr> <chr> <int>
#> 1 PEN001 male 0
#> 2 PEN002 male 0
#> 3 PEN003 female 2
#> 4 PEN004 female 4
#> 5 PEN005 male 2
#> 6 PEN006 male 6
#> 7 PEN007 female 6
#> 8 PEN008 male 5
Created on 2022-01-29 by the reprex package (v2.0.1)