One way would be to use the mutate
function from the dplyr
package to change the column. You could then recode the values with the recode
function (also from dplyr
) in the following way.
df <- data.frame("Year" = c(2021,2021,2021),
"Value" = c(358,723,287),
"Country" = c("FR","USA","IE"))
#install.packages("dplyr") #if you don't have dplyr
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
mutate(df,
Country = recode(Country,
"FR" = "France",
"USA" = "United States",
"IE" = "Ireland"))
#> Year Value Country
#> 1 2021 358 France
#> 2 2021 723 United States
#> 3 2021 287 Ireland
Created on 2021-04-15 by the reprex package (v0.3.0)