It's hard to help without a reprex or some data at least. Please look at the FAQ.
It probably fails because final is a data frame and you should use as.character for a vector; either directly or using mutate() from the dplyr package.
final1 <- final
final1$Sex <- as.character(final1$Sex)
# Or: final1 <- final %>% mutate(Sex = as.character(Sex))