Rename data in more than one column

rename() is for renaming columns not values from a column. There are several ways to accomplish this task, this is one of them.

library(dplyr)
library(stringr)

# Sample data in a copy/paste friendly format. Replace this with your own data frame
Base <- data.frame(
    PAIS_ORIGEN = "AR - ARGENTINA",
    PAIS_PROCEDENCIA = "BR - BRAZIL"
)

#Relevant code
Base %>%
    mutate(across(c(PAIS_ORIGEN, PAIS_PROCEDENCIA), ~ str_remove(.x, "^.{2}\\s-\\s")))
#>   PAIS_ORIGEN PAIS_PROCEDENCIA
#> 1   ARGENTINA           BRAZIL

Created on 2023-03-03 with reprex v2.0.2

Note: Next time please provide a proper REPRoducible EXample (reprex) illustrating your issue.

1 Like