I need some help trying to figure out what is going on with this possibly function. My cast_first list has 65000 names that I need to loop through, but special characters are throwing errors that I need to get around.
I built this function and tried to use mapply to call it, but I'm getting this error
Error in .f(.x[[i]], ...) : unused argument (.x[[i]])
Can anyone tell me what I'm doing wrong here and point me in the direction to fix?
get_gender = function(name, year) {
cast_gender <- gender(name, years = year, method = "ssa") %>% .$gender
if(length(gender_prob) == 0) {
cast_gender <- "Unknown" %>% append(cast_gender,.)
} else {
cast_gender <- append(cast_gender,gender_prob)
}
}
possibly_gender = function() {
possibly(mapply(FUN = get_gender, name = cast_first, year = cast_year),otherwise = "NA", quiet = TRUE)
}
test <- cast_first %>% map(possibly_gender)