I was able to change the encoding of a dataframe using the code provided in R- Changing encoding of column in dataframe?, but I would like to use map instead of a for loop, but I wasn't able to do so and can't figure out why. I intend to use it a piped workflow which using for loops will be very cumbersome.
# Example of the data:
dat <- structure(list(CNES = c("0137162", "0137170", "0137189", "0137197",
"0137200", "0137219"), CPF_CNPJ = c("87768735000148", "03005201000170",
"00000000000000", "00000000000000", "00000000000000", "87775334000115"
), FANTASIA = c("HOSPITAL DE CARIDADE E BENEFIC\xcaNCIA", "COELHO & JUNG INSTITUTO DE OFTALMOLOGIA LTDA",
"UNIDADE SANIT\xc1RIA 03 - PR\xc9DIO HOSPITAL DA LIGA", "UNIDADE SANIT\xc1RIA 11 - BOSQUE",
"PROGRAMA DE SA\xdaDE DA FAM\xcdLIA 01 - BAIRRO PROMORAR", "SIND TRAB IND ALIMENTA\xc7\xc3O"
), RAZ_SOCI = c("CNPJ 87.768.735/0001-48-HOSPITAL DE CARIDADE E BENEFIC\xcaNCIA",
"CNPJ 03.005.201/0001-70-COELHO & JUNG INSTITUTO DE OFTALMOLOGIA LTDA",
"CNPJ 00.000.000/0000-00-PREFEITURA MUNICIPAL DE CACHOEIRA DO SUL",
"CNPJ 00.000.000/0000-00-PREFEITURA MUNICIPAL DE CACHOEIRA DO SUL",
"CNPJ 00.000.000/0000-00-PREFEITURA MUNICIPAL DE CACHOEIRA DO SUL",
"CNPJ 87.775.334/0001-15-SINDICATO DOS TRABALHADORES NA INDUSTRIA DA ALIMENTA\xc7\xc3O"
)), row.names = c("1", "2", "3", "4", "5", "6"), class = "data.frame")
# Using map
dat %>%
map(~ Encoding(.x) <- "latin1")