Consider that I have df
like this:
df <- tribble(
~Country,
"Bangladesh",
"India",
"Nigeria",
"China",
"France",
"Canada",
)
and I only wanted to change some names not all. For instance, only China and France. I tried the below code but it repalces NA for the rest.
shortNames = c("China" = "CHN", "France" = "FR")
df$Country <- shortNames[df$Country]