To replace character values in a data frame with NA, you can use the following syntax:
df[ df == "foo" ] <- NA
Note that if you were trying to replace NA with "foo", the reverse will not work
(df[ df == NA ] = "foo")
You would need to use
df[is.na(df)] <- "foo"
If you want to explore more in R programming then watch this R programming tutorial for beginner: