Situation:
I have a large dataset with a column for country code (country
) and next to it a column with the country name (country_name
). I need help replacing the NA values for the two observations in the country
column with NA in the corresponding country_name
column:
- EL
- UK
EL should have Greece in the country_name column. UK should have United Kingdom in the country_name column.
I am in the process of tidying the dataset, so the solution would be used in my cleaning for the dataset as a whole. Obviously, I would like to keep the remaining columns as is given that the country
column has the correct information in the country_name
column.
Reproducible Data:
structure(list(country = c("EL", "EL", "EL", "EL", "EL", "UK",
"UK", "UK", "UK", "UK"), country_name = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), type = c("Conventional thermal",
"Conventional thermal", "Conventional thermal", "Nuclear", "Nuclear",
"Conventional thermal", "Conventional thermal", "Conventional thermal",
"Nuclear", "Nuclear")), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))