I want to find the number(count) of unique males, females and neutrals in my dataset.
# create a reproducible dataframe
gender <- c("Male", "Male", "Female", "Male","Female", "Female","Neutral","Neutral", "Neutral")
name <- c("Alex", "Andrew", "Amelie","Alex","Amelie", "Amelie", "Amanda", "Amber", "Alessia")
df <- cbind(gender, name)
df <- as.data.frame(df)
Here is what I tried but it isn't what I want:
by_gender <- df %>%
group_by(gender, name) %>%
count(gender)
I want to write a line of code that tells me that there are 2 unique "males", 1 unique "female" and 3 unique "Neutrals" in my dataset.