Suppose I have NA values under a variable, Font in my df. How can replace the NA values based on matching values under the variable, Group? For instance, I want all rows where Group = 1 to have Arial as the Font and all rows where Group = 2 to have Helvetica as the Font. I am aware that I can do the following: df$Font[df$Group==1]<-"Arial" or use recode() from the 'car' package. However, suppose that there are thousands of different groups and fonts, and I don't want to keep typing each of them out in my code.
Example data:
Group Font
1 Arial
1 NA
2 NA
2 Helvetica