Error calling gender in dataframe

I have a data frame that I read from a csv file. the contents of the data frame are as follows.

       NAME CURR_GENDER COUNT
1       LESLIE          N   186
2        COREY          N    86
3       KELSEY          N    52
4        DARYL          N    38
5 PRISCIANDARO          N    33
6         SUNG          N    30

I am trying to determine the gender using a gender library with a name and adding output as a column to an existing data frame.

    csv_in <- "Names.csv"

    Names_df <- read.csv(csv_in)

    gender(Names_df$NAME,
     method = "ssa",
     years = c(1930, 2012)) %>%
     do.call(rbind.data.frame, .)

However, I get the following error. Hoping you can point out what I'm doing wrong here.

Gender error (Names_df $ NAME, method = "ssa", years = c (1930, 2012)): Data must be a character vector.

+4
source share
1 answer

The error tells you that Names_df$NAMEit is not a character vector, but should be. Try to run

Names_df$NAME <- as.character(Names_df$NAME) 

. , class(Names_df$NAME) , .

+1

Source: https://habr.com/ru/post/1599530/


All Articles