I'm trying to "guess" the gender with the first name of a person. I understand that there is a gender package, but I want to utilize it using my own data.
As a beginner, I attempted to copy the gender package's code, but it returned empty results.
This is my database named namestat.
dput(head(namestat,10))
structure(list(name = c("AABIA", "AABIDA", "AABISH", "AADARSH", 
"AADIA", "AAEISHA", "AAESHA", "AAFAF", "AAFIA", "AAFIRA"), female = c(1, 
2, 1, 2, 1, 1, 1, 1, 19, 1), male = c(0, 0, 0, 0, 0, 0, 0, 0, 
0, 0)), row.names = c(NA, 10L), class = "data.frame")
This is the code:
function(names) {
    namestat %>%
        filter(name %in% tolower(names)) %>%
        group_by(name) %>%
        summarise(female = sum(female),
                  male = sum(male)) %>%
        mutate(proportion_male = round((male / (male + female)),
                                       digits = 4),
               proportion_female = round((female / (male + female)),
                                         digits = 4)) %>%
        mutate(gender = ifelse(proportion_female == 0.5, "either",
                               ifelse(proportion_female > 0.5, "female",
                                      "male"))) %>%
        select(name, proportion_male, proportion_female, gender)
}
I expect the output with genderfunc("AABIA")
 name  proportion_male proportion_female gender
  <chr>           <dbl>             <dbl> <chr>  
1 AABIA            0             1     female 
but currently I receive an empty result.
 
    