The approach in the question to recoding the race
factor looks fine.
It seems that the real problem here was omitting the NA
s from the plot. Just subset the data frame:
ggplot(data =
df[!is.na(df$race),]
, aes(x=race)) + geom_bar()
Further reading: