Can't fix this error, transforming long dataframe

Have a dataframe:

structure(list(Cod = c("007", "009", "011", "014", "016"), Municipio = c("Huelmo", 
"Busdongo", "Duero", "Coin", "Anduva"), A1 = c("PSOE", "PP", 
"PSOE", "PSOE", "PSOE"), A2 = c("00000248", "00000044", "00000089", 
"00001637", "00000148"), A3 = c("05030", "03928", "08240", "03968", 
"05016"), B1 = c("PP", "PSOE", "VOX", "PP", "PP"), B2 = c("00000072", 
"00000033", "00000002", "00000924", "00000077"), B3 = c("01460", 
"02946", "00185", "02240", "02610"), C1 = c("PODEMOS", "PODEMOS", 
"PP", "Cs", "Cs"), C2 = c("00000066", "00000020", "00000002", 
"00000386", "00000018"), C3 = c("01338", "01785", "00185", "00935", 
"00610"), D1 = c("VOX", "VOX", "Cs", "PODEMOS", "VOX"), D2 = c("00000041", 
"00000004", "00000002", "00000296", "00000015"), D3 = c("00831", 
"00357", "00185", "00717", "00508"), E1 = c("Cs", "Cs", "CEUS", 
"CEUS", "PODEMOS"), E2 = c("00000021", "00000003", "00000001", 
"00000247", "00000015"), E3 = c("00425", "00267", "00092", "00598", 
"00508"), F1 = c("PH", "CEUS", "AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", 
"AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", "FE de las JONS"
), F2 = c("00000009", "00000002", "00000001", "00000146", "00000001"
), F3 = c("00182", "00178", "00092", "00353", "00033"), G1 = c("RECORTES CERO", 
"AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", "PCPE/PCPC", 
"VOX", "IZQESP"), G2 = c("00000006", "00000001", "00000001", 
"00000107", "00000000"), G3 = c("00121", "00089", "00092", "00259", 
"00000"), H1 = c("JUNTS-UE", "PCTE", "PACMA", "JUNTS-UE", "CEUS"
), H2 = c("00000003", "00000001", "00000001", "00000058", "00000000"
), H3 = c("00060", "00089", "00092", "00140", "00000"), I1 = c("CEUS", 
"IZQESP", "FE de las JONS", "ANDALUCISTAS", "FO"), I2 = c("00000002", 
"00000000", "00000001", "00000045", "00000000"), I3 = c("00040", 
"00000", "00092", "00109", "00000"), J1 = c("AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", 
"FO", "PH", "IZQP - UNIDOS - DEf", "AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)"
), J2 = c("00000002", "00000000", "00000001", "00000028", "00000000"
), J3 = c("00040", "00000", "00092", "00067", "00000"), K1 = c("PIRATES.CAT / REBELDES", 
"JUNTS-UE", "RECORTES CERO", "PCPE/PCPC", "JUNTS-UE"), K2 = c("00000002", 
"00000000", "00000001", "00000025", "00000000"), K3 = c("00040", 
"00000", "00092", "00060", "00000"), L1 = c("PACMA", "ANDALUCISTAS", 
"IZQESP", "PH", "ANDALUCISTAS"), L2 = c("00000001", "00000000", 
"00000000", "00000016", "00000000"), L3 = c("00020", "00000", 
"00000", "00038", "00000"), M1 = c("IZQESP", "IE", "FO", "VOLT", 
"IE"), M2 = c("00000000", "00000000", "00000000", "00000016", 
"00000000"), M3 = c("00000", "00000", "00000", "00038", "00000"
), N1 = c("FO", "ESCAĂ‘OS EN BLANCO", "JUNTS-UE", "FE de las JONS", 
"ESCAĂ‘OS EN BLANCO"), N2 = c("00000000", "00000000", "00000000", 
"00000015", "00000000"), N3 = c("00000", "00000", "00000", "00036", 
"00000"), O1 = c("ANDALUCISTAS", "CRT", "ANDALUCISTAS", "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
"CRT"), O2 = c("00000000", "00000000", "00000000", "00000013", 
"00000000"), O3 = c("00000", "00000", "00000", "00031", "00000"
), P1 = c("IE", "PFAC", "IE", "FO", "PFAC"), P2 = c("00000000", 
"00000000", "00000000", "00000011", "00000000"), P3 = c("00000", 
"00000", "00000", "00026", "00000"), Q1 = c("ESCAĂ‘OS EN BLANCO", 
"PCPE/PCPC", "ESCAĂ‘OS EN BLANCO", "PCTE", "PCTE"), Q2 = c("00000000", 
"00000000", "00000000", "00000009", "00000000"), Q3 = c("00000", 
"00000", "00000", "00021", "00000"), R1 = c("CRT", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
"CRT", "RECORTES CERO", "PCPE/PCPC"), R2 = c("00000000", "00000000", 
"00000000", "00000006", "00000000"), R3 = c("00000", "00000", 
"00000", "00014", "00000"), S1 = c("PFAC", "P-LIB", "PODEMOS", 
"PIRATES.CAT / REBELDES", "SALAMANCA-ZAMORA-LEĂ“N PREPAL"), S2 = c("00000000", 
"00000000", "00000000", "00000006", "00000000"), S3 = c("00000", 
"00000", "00000", "00014", "00000"), T1 = c("PCTE", "SUMAR", 
"PFAC", "IZQESP", "P-LIB"), T2 = c("00000000", "00000000", "00000000", 
"00000004", "00000000"), T3 = c("00000", "00000", "00000", "00009", 
"00000"), U1 = c("PCPE/PCPC", "PACMA", "PCTE", "IE", "SUMAR"), 
    U2 = c("00000000", "00000000", "00000000", "00000003", "00000000"
    ), U3 = c("00000", "00000", "00000", "00007", "00000"), V1 = c("SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
    "CREE EN EUROPA", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", "PACMA", 
    "PACMA"), V2 = c("00000000", "00000000", "00000000", "00000003", 
    "00000000"), V3 = c("00000", "00000", "00000", "00007", "00000"
    ), W1 = c("P-LIB", "PMR", "P-LIB", "ESCAĂ‘OS EN BLANCO", 
    "CREE EN EUROPA"), W2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), W3 = c("00000", "00000", "00000", 
    "00000", "00000"), X1 = c("SUMAR", "S.A.L.F", "SUMAR", "CRT", 
    "PMR"), X2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), X3 = c("00000", "00000", "00000", "00000", "00000"
    ), Y1 = c("CREE EN EUROPA", "F", "CREE EN EUROPA", "PFAC", 
    "S.A.L.F"), Y2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), Y3 = c("00000", "00000", "00000", "00000", "00000"
    ), Z1 = c("PMR", "EXISTE", "PMR", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
    "F"), Z2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), Z3 = c("00000", "00000", "00000", "00000", "00000"
    ), AA1 = c("S.A.L.F", "FE de las JONS", "S.A.L.F", "P-LIB", 
    "EXISTE"), AA2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), AA3 = c("00000", "00000", "00000", "00000", 
    "00000"), AB1 = c("F", "SAE", "F", "SUMAR", "SAE"), AB2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AB3 = c("00000", 
    "00000", "00000", "00000", "00000"), AC1 = c("EXISTE", "J.U.E.X.", 
    "EXISTE", "CREE EN EUROPA", "J.U.E.X."), AC2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AC3 = c("00000", 
    "00000", "00000", "00000", "00000"), AD1 = c("FE de las JONS", 
    "PH", "SAE", "PMR", "PH"), AD2 = c("00000000", "00000000", 
    "00000000", "00000000", "00000000"), AD3 = c("00000", "00000", 
    "00000", "00000", "00000"), AE1 = c("SAE", "VOLT", "J.U.E.X.", 
    "S.A.L.F", "VOLT"), AE2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), AE3 = c("00000", "00000", "00000", 
    "00000", "00000"), AF1 = c("J.U.E.X.", "RECORTES CERO", "VOLT", 
    "F", "RECORTES CERO"), AF2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), AF3 = c("00000", "00000", "00000", 
    "00000", "00000"), AG1 = c("VOLT", "PAZ SOBERANĂŤA REPĂšBLICA", 
    "PAZ SOBERANĂŤA REPĂšBLICA", "EXISTE", "PAZ SOBERANĂŤA REPĂšBLICA"
    ), AG2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), AG3 = c("00000", "00000", "00000", "00000", 
    "00000"), AH1 = c("PAZ SOBERANĂŤA REPĂšBLICA", "FIEL", "FIEL", 
    "SAE", "FIEL"), AH2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), AH3 = c("00000", "00000", "00000", 
    "00000", "00000"), AI1 = c("FIEL", "IZQP - UNIDOS - DEf", 
    "IZQP - UNIDOS - DEf", "J.U.E.X.", "IZQP - UNIDOS - DEf"), 
    AI2 = c("00000000", "00000000", "00000000", "00000000", "00000000"
    ), AI3 = c("00000", "00000", "00000", "00000", "00000"), 
    AJ1 = c("IZQP - UNIDOS - DEf", "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
    "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", "PAZ SOBERANĂŤA REPĂšBLICA", 
    "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX"), AJ2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AJ3 = c("00000", 
    "00000", "00000", "00000", "00000"), AK1 = c("EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
    "glg", "glg", "FIEL", "glg"), AK2 = c("00000000", "00000000", 
    "00000000", "00000000", "00000000"), AK3 = c("00000", "00000", 
    "00000", "00000", "00000"), AL1 = c("glg", "PIRATES.CAT / REBELDES", 
    "PIRATES.CAT / REBELDES", "glg", "PIRATES.CAT / REBELDES"
    ), AL2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), AL3 = c("00000", "00000", "00000", "00000", 
    "00000"), AM1 = c("NEX", "NEX", "NEX", "NEX", "NEX"), AM2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AM3 = c("00000", 
    "00000", "00000", "00000", "00000")), row.names = c(NA, -5L
), class = c("tbl_df", "tbl", "data.frame"))

First, I transform the numbers that are in character format to numeric format.

col_voto <- c("Cod","A2","A3","B2","B3","C2","C3","D2","D3","E2","E3","F2","F3","G2","G3","H2","H3","I2","I3","J2","J3","K2","K3","L2","L3","M2","M3","N2","N3","O2","O3",
              "P2","P3","Q2","Q3","R2","R3","S2","S3","T2","T3","U2","U3","V2","V3","W2","W3","X2","X3","Y2","Y3","Z2","Z3","AA2","AA3","AB2","AB3","AC2","AC3","AD2","AD3",
              "AE2","AE3","AF2","AF3","AG2","AG3","AH2","AH3","AI2","AI3","AJ2","AJ3","AK2","AK3","AL2","AL3","AM2","AM3")

and then

df <- df %>%
        mutate(across(all_of(col_voto), as.numeric))

Then create and apply a function to isolate each section of the data.

stack_data = function(i) {
        d = select(europeas, Municipio, contains(i), -Cod)
        names(d) = str_replace(names(d), i, 'col')
        d
}

and map through "sections" A-AM, stack, and reshape

df <- map_df(c('A', 'B','C', 'D', 'E', 'F', 'G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG',
                     'AH','AI','AJ','AK','AL','AM'), stack_data) |>
        filter(!is.na(col1)) |>
        pivot_longer(c(-'Municipio', -'col1')) |>
        pivot_wider(names_from = c(col1, name), values_from = value) |>
        select(Municipio, contains('PSOE'), contains('PP'), contains('IZQESP'), contains('CEUS'), contains('EL PI'), contains('CCa'), contains('GBAI'),
               contains('EAJ-PNV'), contains('FO'), contains('AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)'), contains('JUNTS-UE'), contains('ANDALUCISTAS'), 
               contains('IE'), contains('VOX'), contains('ESCAĂ‘OS EN BLANCO'), contains('CRT'), contains('PODEMOS'), contains('PFAC'), contains('PCTE'), contains('PCTC'), 
               contains('PCPE/PCPC'), contains('SALAMANCA-ZAMORA-LEĂ“N PREPAL'), contains('P-LIB'),  contains('SUMAR'),contains('PACMA'),  contains('CREE EN EUROPA'),
               contains('PMR'), contains('S.A.L.F'), contains('F'), contains('EXISTE'), contains('Cs'), contains('FE de las JONS'), contains('SAE'), contains('J.U.E.X.'), 
               contains('PH'), contains('VOLT'), contains('RECORTES CERO'), contains('PAZ SOBERANĂŤA REPĂšBLICA'),  contains('FIEL'),contains('IZQP - UNIDOS - DEf'),  
               contains('EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX'), contains('glg'), contains('PIRATES.CAT / REBELDES'), contains('NEX')) |>
        mutate_all(~replace_na(., 0)) 

I got this error:

Error in `pivot_longer()`:
! Can't combine `col2` <double> and `colA1` <character>.

I want to achieve this:

I'm completely stuck. Sorry for long post.

Long is fine, but you should make sure the data and code you share reproduce the error you encounter so that folks here can help right away: Could you 1) select the code you need to reproduce the error — including the structure() call you posted here — then 2) run "Reprex selection" from the "Addins" menu, 3) review the corresponding output to make sure it's the same as what you get in your console, and only then 4) immediately use Ctrl-V or Command-V to paste the result here?

I second @ dromano request but also
in

stack_data = function(i) {
        d = select(europeas, Municipio, contains(i), -Cod)
        names(d) = str_replace(names(d), i, 'col')
        d
}

What is "europeas"?

When I try your code I get


Error in `map()`:
â„ą In index: 1.
Caused by error in `.f()`:
! object 'europeas' not found
Run `rlang::last_trace()` to see where the error occurred.

Hope this helps

df <- structure(list(Cod = c("007", "009", "011", "014", "016"), Municipio = c("Huelmo", 
"Busdongo", "Duero", "Coin", "Anduva"), A1 = c("PSOE", "PP", 
"PSOE", "PSOE", "PSOE"), A2 = c("00000248", "00000044", "00000089", 
"00001637", "00000148"), A3 = c("05030", "03928", "08240", "03968", 
"05016"), B1 = c("PP", "PSOE", "VOX", "PP", "PP"), B2 = c("00000072", 
"00000033", "00000002", "00000924", "00000077"), B3 = c("01460", 
"02946", "00185", "02240", "02610"), C1 = c("PODEMOS", "PODEMOS", 
"PP", "Cs", "Cs"), C2 = c("00000066", "00000020", "00000002", 
"00000386", "00000018"), C3 = c("01338", "01785", "00185", "00935", 
"00610"), D1 = c("VOX", "VOX", "Cs", "PODEMOS", "VOX"), D2 = c("00000041", 
"00000004", "00000002", "00000296", "00000015"), D3 = c("00831", 
"00357", "00185", "00717", "00508"), E1 = c("Cs", "Cs", "CEUS", 
"CEUS", "PODEMOS"), E2 = c("00000021", "00000003", "00000001", 
"00000247", "00000015"), E3 = c("00425", "00267", "00092", "00598", 
"00508"), F1 = c("PH", "CEUS", "AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", 
"AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", "FE de las JONS"
), F2 = c("00000009", "00000002", "00000001", "00000146", "00000001"
), F3 = c("00182", "00178", "00092", "00353", "00033"), G1 = c("RECORTES CERO", 
"AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", "PCPE/PCPC", 
"VOX", "IZQESP"), G2 = c("00000006", "00000001", "00000001", 
"00000107", "00000000"), G3 = c("00121", "00089", "00092", "00259", 
"00000"), H1 = c("JUNTS-UE", "PCTE", "PACMA", "JUNTS-UE", "CEUS"
), H2 = c("00000003", "00000001", "00000001", "00000058", "00000000"
), H3 = c("00060", "00089", "00092", "00140", "00000"), I1 = c("CEUS", 
"IZQESP", "FE de las JONS", "ANDALUCISTAS", "FO"), I2 = c("00000002", 
"00000000", "00000001", "00000045", "00000000"), I3 = c("00040", 
"00000", "00092", "00109", "00000"), J1 = c("AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", 
"FO", "PH", "IZQP - UNIDOS - DEf", "AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)"
), J2 = c("00000002", "00000000", "00000001", "00000028", "00000000"
), J3 = c("00040", "00000", "00092", "00067", "00000"), K1 = c("PIRATES. CAT / REBELDES", 
"JUNTS-UE", "RECORTES CERO", "PCPE/PCPC", "JUNTS-UE"), K2 = c("00000002", 
"00000000", "00000001", "00000025", "00000000"), K3 = c("00040", 
"00000", "00092", "00060", "00000"), L1 = c("PACMA", "ANDALUCISTAS", 
"IZQESP", "PH", "ANDALUCISTAS"), L2 = c("00000001", "00000000", 
"00000000", "00000016", "00000000"), L3 = c("00020", "00000", 
"00000", "00038", "00000"), M1 = c("IZQESP", "IE", "FO", "VOLT", 
"IE"), M2 = c("00000000", "00000000", "00000000", "00000016", 
"00000000"), M3 = c("00000", "00000", "00000", "00038", "00000"
), N1 = c("FO", "ESCAĂ‘OS EN BLANCO", "JUNTS-UE", "FE de las JONS", 
"ESCAĂ‘OS EN BLANCO"), N2 = c("00000000", "00000000", "00000000", 
"00000015", "00000000"), N3 = c("00000", "00000", "00000", "00036", 
"00000"), O1 = c("ANDALUCISTAS", "CRT", "ANDALUCISTAS", "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
"CRT"), O2 = c("00000000", "00000000", "00000000", "00000013", 
"00000000"), O3 = c("00000", "00000", "00000", "00031", "00000"
), P1 = c("IE", "PFAC", "IE", "FO", "PFAC"), P2 = c("00000000", 
"00000000", "00000000", "00000011", "00000000"), P3 = c("00000", 
"00000", "00000", "00026", "00000"), Q1 = c("ESCAĂ‘OS EN BLANCO", 
"PCPE/PCPC", "ESCAĂ‘OS EN BLANCO", "PCTE", "PCTE"), Q2 = c("00000000", 
"00000000", "00000000", "00000009", "00000000"), Q3 = c("00000", 
"00000", "00000", "00021", "00000"), R1 = c("CRT", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
"CRT", "RECORTES CERO", "PCPE/PCPC"), R2 = c("00000000", "00000000", 
"00000000", "00000006", "00000000"), R3 = c("00000", "00000", 
"00000", "00014", "00000"), S1 = c("PFAC", "P-LIB", "PODEMOS", 
"PIRATES. CAT / REBELDES", "SALAMANCA-ZAMORA-LEĂ“N PREPAL"), S2 = c("00000000", 
"00000000", "00000000", "00000006", "00000000"), S3 = c("00000", 
"00000", "00000", "00014", "00000"), T1 = c("PCTE", "SUMAR", 
"PFAC", "IZQESP", "P-LIB"), T2 = c("00000000", "00000000", "00000000", 
"00000004", "00000000"), T3 = c("00000", "00000", "00000", "00009", 
"00000"), U1 = c("PCPE/PCPC", "PACMA", "PCTE", "IE", "SUMAR"), 
U2 = c("00000000", "00000000", "00000000", "00000003", "00000000"
), U3 = c("00000", "00000", "00000", "00007", "00000"), V1 = c("SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
"CREE EN EUROPA", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", "PACMA", 
"PACMA"), V2 = c("00000000", "00000000", "00000000", "00000003", 
"00000000"), V3 = c("00000", "00000", "00000", "00007", "00000"
), W1 = c("P-LIB", "PMR", "P-LIB", "ESCAĂ‘OS EN BLANCO", 
"CREE EN EUROPA"), W2 = c("00000000", "00000000", "00000000", 
"00000000", "00000000"), W3 = c("00000", "00000", "00000", 
"00000", "00000"), X1 = c("SUMAR", "S. A. L. F", "SUMAR", "CRT", 
"PMR"), X2 = c("00000000", "00000000", "00000000", "00000000", 
"00000000"), X3 = c("00000", "00000", "00000", "00000", "00000"
), Y1 = c("CREE EN EUROPA", "F", "CREE EN EUROPA", "PFAC", 
"S. A. L. F"), Y2 = c("00000000", "00000000", "00000000", "00000000", 
"00000000"), Y3 = c("00000", "00000", "00000", "00000", "00000"
), Z1 = c("PMR", "EXISTE", "PMR", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
"F"), Z2 = c("00000000", "00000000", "00000000", "00000000", 
"00000000"), Z3 = c("00000", "00000", "00000", "00000", "00000"
), AA1 = c("S. A. L. F", "FE de las JONS", "S. A. L. F", "P-LIB", 
"EXISTE"), AA2 = c("00000000", "00000000", "00000000", "00000000", 
"00000000"), AA3 = c("00000", "00000", "00000", "00000", 
"00000"), AB1 = c("F", "SAE", "F", "SUMAR", "SAE"), AB2 = c("00000000", 
"00000000", "00000000", "00000000", "00000000"), AB3 = c("00000", 
"00000", "00000", "00000", "00000"), AC1 = c("EXISTE", "J. U. E. X.", 
"EXISTE", "CREE EN EUROPA", "J. U. E. X."), AC2 = c("00000000", 
"00000000", "00000000", "00000000", "00000000"), AC3 = c("00000", 
"00000", "00000", "00000", "00000"), AD1 = c("FE de las JONS", 
"PH", "SAE", "PMR", "PH"), AD2 = c("00000000", "00000000", 
"00000000", "00000000", "00000000"), AD3 = c("00000", "00000", 
"00000", "00000", "00000"), AE1 = c("SAE", "VOLT", "J. U. E. X.", 
"S. A. L. F", "VOLT"), AE2 = c("00000000", "00000000", "00000000", 
"00000000", "00000000"), AE3 = c("00000", "00000", "00000", 
"00000", "00000"), AF1 = c("J. U. E. X.", "RECORTES CERO", "VOLT", 
"F", "RECORTES CERO"), AF2 = c("00000000", "00000000", "00000000", 
"00000000", "00000000"), AF3 = c("00000", "00000", "00000", 
"00000", "00000"), AG1 = c("VOLT", "PAZ SOBERANĂŤA REPĂšBLICA", 
"PAZ SOBERANĂŤA REPĂšBLICA", "EXISTE", "PAZ SOBERANĂŤA REPĂšBLICA"
), AG2 = c("00000000", "00000000", "00000000", "00000000", 
"00000000"), AG3 = c("00000", "00000", "00000", "00000", 
"00000"), AH1 = c("PAZ SOBERANĂŤA REPĂšBLICA", "FIEL", "FIEL", 
"SAE", "FIEL"), AH2 = c("00000000", "00000000", "00000000", 
"00000000", "00000000"), AH3 = c("00000", "00000", "00000", 
"00000", "00000"), AI1 = c("FIEL", "IZQP - UNIDOS - DEf", 
"IZQP - UNIDOS - DEf", "J. U. E. X.", "IZQP - UNIDOS - DEf"), 
AI2 = c("00000000", "00000000", "00000000", "00000000", "00000000"
), AI3 = c("00000", "00000", "00000", "00000", "00000"), 
AJ1 = c("IZQP - UNIDOS - DEf", "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
"EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", "PAZ SOBERANĂŤA REPĂšBLICA", 
"EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX"), AJ2 = c("00000000", 
"00000000", "00000000", "00000000", "00000000"), AJ3 = c("00000", 
"00000", "00000", "00000", "00000"), AK1 = c("EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
"glg", "glg", "FIEL", "glg"), AK2 = c("00000000", "00000000", 
"00000000", "00000000", "00000000"), AK3 = c("00000", "00000", 
"00000", "00000", "00000"), AL1 = c("glg", "PIRATES. CAT / REBELDES", 
"PIRATES. CAT / REBELDES", "glg", "PIRATES. CAT / REBELDES"
), AL2 = c("00000000", "00000000", "00000000", "00000000", 
"00000000"), AL3 = c("00000", "00000", "00000", "00000", 
"00000"), AM1 = c("NEX", "NEX", "NEX", "NEX", "NEX"), AM2 = c("00000000", 
"00000000", "00000000", "00000000", "00000000"), AM3 = c("00000", 
"00000", "00000", "00000", "00000")), row.names = c(NA, -5L
), class = c("tbl_df", "tbl", "data.frame"))


col_voto <- c("Cod","A2","A3","B2","B3","C2","C3","D2","D3","E2","E3","F2","F3","G2","G3","H2","H3","I2","I3","J2","J3","K2","K3","L2","L3","M2","M3","N2","N3","O2","O3",        "P2","P3","Q2","Q3","R2","R3","S2","S3","T2","T3","U2","U3","V2","V3","W2","W3","X2","X3","Y2","Y3","Z2","Z3","AA2","AA3","AB2","AB3","AC2","AC3","AD2","AD3",
"AE2","AE3","AF2","AF3","AG2","AG3","AH2","AH3","AI2","AI3","AJ2","AJ3","AK2","AK3","AL2","AL3","AM2","AM3")

df <- df %>%
        mutate(across(all_of(col_voto), as.numeric))
#> Error in df %>% mutate(across(all_of(col_voto), as.numeric)): could not find function "%>%"
stack_data = function(i) {
        d = select(df, Municipio, contains(i), -Cod)
        names(d) = str_replace(names(d), i, 'col')
        d
}

df <- map_df(c('A', 'B','C', 'D', 'E', 'F', 'G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG',
               'AH','AI','AJ','AK','AL','AM'), stack_data) |>
        filter(!is.na(col1)) |>
        pivot_longer(c(-'Municipio', -'col1')) |>
        pivot_wider(names_from = c(col1, name), values_from = value) |>
        select(Municipio, contains('PSOE'), contains('PP'), contains('IZQESP'), contains('CEUS'), contains('EL PI'), contains('CCa'), contains('GBAI'),
               contains('EAJ-PNV'), contains('FO'), contains('AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)'), contains('JUNTS-UE'), contains('ANDALUCISTAS'), 
               contains('IE'), contains('VOX'), contains('ESCAĂ‘OS EN BLANCO'), contains('CRT'), contains('PODEMOS'), contains('PFAC'), contains('PCTE'), contains('PCTC'), 
               contains('PCPE/PCPC'), contains('SALAMANCA-ZAMORA-LEĂ“N PREPAL'), contains('P-LIB'),  contains('SUMAR'),contains('PACMA'),  contains('CREE EN EUROPA'),
               contains('PMR'), contains('S.A.L.F'), contains('F'), contains('EXISTE'), contains('Cs'), contains('FE de las JONS'), contains('SAE'), contains('J.U.E.X.'), 
               contains('PH'), contains('VOLT'), contains('RECORTES CERO'), contains('PAZ SOBERANĂŤA REPĂšBLICA'),  contains('FIEL'),contains('IZQP - UNIDOS - DEf'),  
               contains('EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX'), contains('glg'), contains('PIRATES.CAT / REBELDES'), contains('NEX')) |>
        mutate_all(~replace_na(., 0))
#> Error in mutate_all(select(pivot_wider(pivot_longer(filter(map_df(c("A", : could not find function "mutate_all"

Created on 2024-05-29 with reprex v2.1.0

1 Like

Sorry. Instead of "europeas" it should say "df".

Thanks, José — this is probably enough, but for future reference, the fact that errors like this one appear in your output:

means that you didn't include loading all the packages that are needed to run your code before you ran the reprex addin.

First off, just as an FYI, the line filter(!is.na(col1)) does not do anything in this code, the tibble stays 195x47.
Second, the reason why the pivot_longer() does not work, is because columns in a dataframe need to be the same data type. With this code you are putting the original column names in a new column - that's fine. But then you are also putting the contents of those original columns all in one column: but some are numeric (e.g. col2, col3, etc) and some are characters (e.g. colA1, colA2, etc). The function has an optional argument values_transform for which the help file says: " If not specified, the type of the columns generated from names_to will be character, and the type of the variables generated from values_to will be the common type of the input columns used to generate them.". And in your case, there is no common data type, there are different data types and pivot_longer() does not want to coerce data types from one to the other.
If you run the code without the part that transforms the numbers from character to numeric, the pivot_longer() works. However, you then get a warning for the pivot_wider(): Warning message: Values from value are not uniquely identified; output will contain list-cols. Which I am sure you don't want (every column is now a list, and you end up with 1756 columns).

Okay - so after trying to figure out what you want exactly, I think the function is maybe also not creating what you think it is creating? If I run your code as-is, up to the map_df() line only, it produces:

# A tibble: 195 Ă— 47
   Municipio col1   col2  col3 colA1   colA2 colA3 colB1 colB2 colB3 colC1 colC2 colC3 colD1 colD2 colD3
   <chr>     <chr> <dbl> <dbl> <chr>   <dbl> <dbl> <chr> <dbl> <dbl> <chr> <dbl> <dbl> <chr> <dbl> <dbl>
 1 Huelmo    PSOE    248  5030 S. A. …     0     0 F         0     0 EXIS…     0     0 FE d…     0     0
 2 Busdongo  PP       44  3928 FE de …     0     0 SAE       0     0 J. U…     0     0 PH        0     0
 3 Duero     PSOE     89  8240 S. A. …     0     0 F         0     0 EXIS…     0     0 SAE       0     0
 4 Coin      PSOE   1637  3968 P-LIB       0     0 SUMAR     0     0 CREE…     0     0 PMR       0     0
 5 Anduva    PSOE    148  5016 EXISTE      0     0 SAE       0     0 J. U…     0     0 PH        0     0
 6 Huelmo    PP       72  1460 NA         NA    NA NA       NA    NA NA       NA    NA NA       NA    NA
 7 Busdongo  PSOE     33  2946 NA         NA    NA NA       NA    NA NA       NA    NA NA       NA    NA
 8 Duero     VOX       2   185 NA         NA    NA NA       NA    NA NA       NA    NA NA       NA    NA
 9 Coin      PP      924  2240 NA         NA    NA NA       NA    NA NA       NA    NA NA       NA    NA
10 Anduva    PP       77  2610 NA         NA    NA NA       NA    NA NA       NA    NA NA       NA    NA
# â„ą 185 more rows
# â„ą 31 more variables: colE1 <chr>, colE2 <dbl>, colE3 <dbl>, colF1 <chr>, colF2 <dbl>, colF3 <dbl>,
#   colG1 <chr>, colG2 <dbl>, colG3 <dbl>, colH1 <chr>, colH2 <dbl>, colH3 <dbl>, colI1 <chr>,
#   colI2 <dbl>, colI3 <dbl>, colJ1 <chr>, colJ2 <dbl>, colJ3 <dbl>, colK1 <chr>, colK2 <dbl>,
#   colK3 <dbl>, colL1 <chr>, colL2 <dbl>, colL3 <dbl>, colM1 <chr>, colM2 <dbl>, colM3 <dbl>,
#   Acol1 <chr>, Acol2 <dbl>, Acol3 <dbl>, colunicipio <chr>
# â„ą Use `print(n = ...)` to see more rows

So the characters in A1, B1, C1 become col1, and all the values in A2, B2, C2, etc go in col2, and A3, B3, C3 etc in col3? But then you also still have colA1, colA2, colA3, etc, all populated with either characters, 0s or NAs...? From the example you are showing, it looks like you don't need/want all this? Why not get rid of those? This code seems to work (see my comments with the piped code part):

# Use same dataset - not shown here, large
col_voto <- c("Cod","A2","A3","B2","B3","C2","C3","D2","D3","E2","E3","F2","F3","G2","G3","H2","H3","I2","I3","J2","J3","K2","K3","L2","L3","M2","M3","N2","N3","O2","O3",        "P2","P3","Q2","Q3","R2","R3","S2","S3","T2","T3","U2","U3","V2","V3","W2","W3","X2","X3","Y2","Y3","Z2","Z3","AA2","AA3","AB2","AB3","AC2","AC3","AD2","AD3",
              "AE2","AE3","AF2","AF3","AG2","AG3","AH2","AH3","AI2","AI3","AJ2","AJ3","AK2","AK3","AL2","AL3","AM2","AM3")

df <- df %>%
  mutate(across(all_of(col_voto), as.numeric)) 

stack_data = function(i) {
  d = select(df, Municipio, starts_with(i), -Cod)
  names(d) = str_replace(names(d), i, 'col')
  d
}

df3 <- map_df(c('A', 'B','C', 'D', 'E', 'F', 'G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG',
               'AH','AI','AJ','AK','AL','AM'), stack_data) |>
  select(Municipio, col1, col2, col3) |> # only select the columns you need
  filter(!is.na(col1)) |> # FYI does nothing, tibble stays 195x47
  filter(!is.na(Municipio)) |> # Is this maybe what you want? Somehow there are 5 rows with NA for Municipio
  pivot_longer(c(-'Municipio', -'col1')) |> # This now works since col2 and col3 are both numeric
  pivot_wider(names_from = c(col1, name), values_from = value) |>
# You now also don't need the select code below anymore
# select(Municipio, contains('PSOE'), contains('PP'), contains('IZQESP'), contains('CEUS'), contains('EL PI'), contains('CCa'), contains('GBAI'),
  #        contains('EAJ-PNV'), contains('FO'), contains('AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)'), contains('JUNTS-UE'), contains('ANDALUCISTAS'),
  #        contains('IE'), contains('VOX'), contains('ESCAĂ‘OS EN BLANCO'), contains('CRT'), contains('PODEMOS'), contains('PFAC'), contains('PCTE'), contains('PCTC'),
  #        contains('PCPE/PCPC'), contains('SALAMANCA-ZAMORA-LEĂ“N PREPAL'), contains('P-LIB'),  contains('SUMAR'),contains('PACMA'),  contains('CREE EN EUROPA'),
  #        contains('PMR'), contains('S.A.L.F'), contains('F'), contains('EXISTE'), contains('Cs'), contains('FE de las JONS'), contains('SAE'), contains('J.U.E.X.'),
  #        contains('PH'), contains('VOLT'), contains('RECORTES CERO'), contains('PAZ SOBERANĂŤA REPĂšBLICA'),  contains('FIEL'),contains('IZQP - UNIDOS - DEf'),
  #        contains('EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX'), contains('glg'), contains('PIRATES.CAT / REBELDES'), contains('NEX')) |>
  mutate_all(~replace_na(., 0))

The final dataframe (I called it df3 to compare with the original) is not exactly the same as the example, but it still contains all the column names that you specified in the select() part, and a few extra (your code did not have PODEMOS in it, but your example did).
Not knowing anything whatsoever about your data, this seems like what you need? If not, please give some more detail.

Edited to that this is the result:

# A tibble: 5 Ă— 79
  Municipio PSOE_col2 PSOE_col3 PP_col2 PP_col3 VOX_col2 VOX_col3 PODEMOS_col2 PODEMOS_col3 Cs_col2
  <chr>         <dbl>     <dbl>   <dbl>   <dbl>    <dbl>    <dbl>        <dbl>        <dbl>   <dbl>
1 Huelmo          248      5030      72    1460       41      831           66         1338      21
2 Busdongo         33      2946      44    3928        4      357           20         1785       3
3 Duero            89      8240       2     185        2      185            0            0       2
4 Coin           1637      3968     924    2240      107      259          296          717     386
5 Anduva          148      5016      77    2610       15      508           15          508      18
# â„ą 69 more variables: Cs_col3 <dbl>, CEUS_col2 <dbl>, CEUS_col3 <dbl>, PH_col2 <dbl>, PH_col3 <dbl>,
#   `AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)_col2` <dbl>,
#   `AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)_col3` <dbl>, `FE de las JONS_col2` <dbl>,
#   `FE de las JONS_col3` <dbl>, `RECORTES CERO_col2` <dbl>, `RECORTES CERO_col3` <dbl>,
#   `PCPE/PCPC_col2` <dbl>, `PCPE/PCPC_col3` <dbl>, IZQESP_col2 <dbl>, IZQESP_col3 <dbl>,
#   `JUNTS-UE_col2` <dbl>, `JUNTS-UE_col3` <dbl>, PCTE_col2 <dbl>, PCTE_col3 <dbl>, PACMA_col2 <dbl>,
#   PACMA_col3 <dbl>, ANDALUCISTAS_col2 <dbl>, ANDALUCISTAS_col3 <dbl>, FO_col2 <dbl>, FO_col3 <dbl>, …
1 Like

How did you import the data that is in the structure() call you shared? Was it originally in an Excel file?

Thanks for all the explanations @GeraldineK, now code works perfectly. And it has helped me a lot to understand where I made several mistakes. It's just what I was looking for. Great help.

1 Like

Hi @dromano, data comes from a csv. Thanks for your interest.

If you look at the table returned by this code, you'll notice that the stack_data() function creates some odd column names, which means that by restricting to the columns to Municipio, col1, col2, col3:

you lose all of the data from the original columns that have more than one letter in their name. It turns out they're not needed because they refer to political parties that received no votes in those municipal districts, but had there been data there, it would have been lost.

Here's an alternative approach that starts from your original csv data (with full reprex at bottom of post):

original data, saved as "df"
structure(list(Cod = c("007", "009", "011", "014", "016"), Municipio = c("Huelmo", 
"Busdongo", "Duero", "Coin", "Anduva"), A1 = c("PSOE", "PP", 
"PSOE", "PSOE", "PSOE"), A2 = c("00000248", "00000044", "00000089", 
"00001637", "00000148"), A3 = c("05030", "03928", "08240", "03968", 
"05016"), B1 = c("PP", "PSOE", "VOX", "PP", "PP"), B2 = c("00000072", 
"00000033", "00000002", "00000924", "00000077"), B3 = c("01460", 
"02946", "00185", "02240", "02610"), C1 = c("PODEMOS", "PODEMOS", 
"PP", "Cs", "Cs"), C2 = c("00000066", "00000020", "00000002", 
"00000386", "00000018"), C3 = c("01338", "01785", "00185", "00935", 
"00610"), D1 = c("VOX", "VOX", "Cs", "PODEMOS", "VOX"), D2 = c("00000041", 
"00000004", "00000002", "00000296", "00000015"), D3 = c("00831", 
"00357", "00185", "00717", "00508"), E1 = c("Cs", "Cs", "CEUS", 
"CEUS", "PODEMOS"), E2 = c("00000021", "00000003", "00000001", 
"00000247", "00000015"), E3 = c("00425", "00267", "00092", "00598", 
"00508"), F1 = c("PH", "CEUS", "AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", 
"AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", "FE de las JONS"
), F2 = c("00000009", "00000002", "00000001", "00000146", "00000001"
), F3 = c("00182", "00178", "00092", "00353", "00033"), G1 = c("RECORTES CERO", 
"AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", "PCPE/PCPC", 
"VOX", "IZQESP"), G2 = c("00000006", "00000001", "00000001", 
"00000107", "00000000"), G3 = c("00121", "00089", "00092", "00259", 
"00000"), H1 = c("JUNTS-UE", "PCTE", "PACMA", "JUNTS-UE", "CEUS"
), H2 = c("00000003", "00000001", "00000001", "00000058", "00000000"
), H3 = c("00060", "00089", "00092", "00140", "00000"), I1 = c("CEUS", 
"IZQESP", "FE de las JONS", "ANDALUCISTAS", "FO"), I2 = c("00000002", 
"00000000", "00000001", "00000045", "00000000"), I3 = c("00040", 
"00000", "00092", "00109", "00000"), J1 = c("AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", 
"FO", "PH", "IZQP - UNIDOS - DEf", "AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)"
), J2 = c("00000002", "00000000", "00000001", "00000028", "00000000"
), J3 = c("00040", "00000", "00092", "00067", "00000"), K1 = c("PIRATES.CAT / REBELDES", 
"JUNTS-UE", "RECORTES CERO", "PCPE/PCPC", "JUNTS-UE"), K2 = c("00000002", 
"00000000", "00000001", "00000025", "00000000"), K3 = c("00040", 
"00000", "00092", "00060", "00000"), L1 = c("PACMA", "ANDALUCISTAS", 
"IZQESP", "PH", "ANDALUCISTAS"), L2 = c("00000001", "00000000", 
"00000000", "00000016", "00000000"), L3 = c("00020", "00000", 
"00000", "00038", "00000"), M1 = c("IZQESP", "IE", "FO", "VOLT", 
"IE"), M2 = c("00000000", "00000000", "00000000", "00000016", 
"00000000"), M3 = c("00000", "00000", "00000", "00038", "00000"
), N1 = c("FO", "ESCAĂ‘OS EN BLANCO", "JUNTS-UE", "FE de las JONS", 
"ESCAĂ‘OS EN BLANCO"), N2 = c("00000000", "00000000", "00000000", 
"00000015", "00000000"), N3 = c("00000", "00000", "00000", "00036", 
"00000"), O1 = c("ANDALUCISTAS", "CRT", "ANDALUCISTAS", "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
"CRT"), O2 = c("00000000", "00000000", "00000000", "00000013", 
"00000000"), O3 = c("00000", "00000", "00000", "00031", "00000"
), P1 = c("IE", "PFAC", "IE", "FO", "PFAC"), P2 = c("00000000", 
"00000000", "00000000", "00000011", "00000000"), P3 = c("00000", 
"00000", "00000", "00026", "00000"), Q1 = c("ESCAĂ‘OS EN BLANCO", 
"PCPE/PCPC", "ESCAĂ‘OS EN BLANCO", "PCTE", "PCTE"), Q2 = c("00000000", 
"00000000", "00000000", "00000009", "00000000"), Q3 = c("00000", 
"00000", "00000", "00021", "00000"), R1 = c("CRT", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
"CRT", "RECORTES CERO", "PCPE/PCPC"), R2 = c("00000000", "00000000", 
"00000000", "00000006", "00000000"), R3 = c("00000", "00000", 
"00000", "00014", "00000"), S1 = c("PFAC", "P-LIB", "PODEMOS", 
"PIRATES.CAT / REBELDES", "SALAMANCA-ZAMORA-LEĂ“N PREPAL"), S2 = c("00000000", 
"00000000", "00000000", "00000006", "00000000"), S3 = c("00000", 
"00000", "00000", "00014", "00000"), T1 = c("PCTE", "SUMAR", 
"PFAC", "IZQESP", "P-LIB"), T2 = c("00000000", "00000000", "00000000", 
"00000004", "00000000"), T3 = c("00000", "00000", "00000", "00009", 
"00000"), U1 = c("PCPE/PCPC", "PACMA", "PCTE", "IE", "SUMAR"), 
    U2 = c("00000000", "00000000", "00000000", "00000003", "00000000"
    ), U3 = c("00000", "00000", "00000", "00007", "00000"), V1 = c("SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
    "CREE EN EUROPA", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", "PACMA", 
    "PACMA"), V2 = c("00000000", "00000000", "00000000", "00000003", 
    "00000000"), V3 = c("00000", "00000", "00000", "00007", "00000"
    ), W1 = c("P-LIB", "PMR", "P-LIB", "ESCAĂ‘OS EN BLANCO", 
    "CREE EN EUROPA"), W2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), W3 = c("00000", "00000", "00000", 
    "00000", "00000"), X1 = c("SUMAR", "S.A.L.F", "SUMAR", "CRT", 
    "PMR"), X2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), X3 = c("00000", "00000", "00000", "00000", "00000"
    ), Y1 = c("CREE EN EUROPA", "F", "CREE EN EUROPA", "PFAC", 
    "S.A.L.F"), Y2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), Y3 = c("00000", "00000", "00000", "00000", "00000"
    ), Z1 = c("PMR", "EXISTE", "PMR", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
    "F"), Z2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), Z3 = c("00000", "00000", "00000", "00000", "00000"
    ), AA1 = c("S.A.L.F", "FE de las JONS", "S.A.L.F", "P-LIB", 
    "EXISTE"), AA2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), AA3 = c("00000", "00000", "00000", "00000", 
    "00000"), AB1 = c("F", "SAE", "F", "SUMAR", "SAE"), AB2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AB3 = c("00000", 
    "00000", "00000", "00000", "00000"), AC1 = c("EXISTE", "J.U.E.X.", 
    "EXISTE", "CREE EN EUROPA", "J.U.E.X."), AC2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AC3 = c("00000", 
    "00000", "00000", "00000", "00000"), AD1 = c("FE de las JONS", 
    "PH", "SAE", "PMR", "PH"), AD2 = c("00000000", "00000000", 
    "00000000", "00000000", "00000000"), AD3 = c("00000", "00000", 
    "00000", "00000", "00000"), AE1 = c("SAE", "VOLT", "J.U.E.X.", 
    "S.A.L.F", "VOLT"), AE2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), AE3 = c("00000", "00000", "00000", 
    "00000", "00000"), AF1 = c("J.U.E.X.", "RECORTES CERO", "VOLT", 
    "F", "RECORTES CERO"), AF2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), AF3 = c("00000", "00000", "00000", 
    "00000", "00000"), AG1 = c("VOLT", "PAZ SOBERANĂŤA REPĂšBLICA", 
    "PAZ SOBERANĂŤA REPĂšBLICA", "EXISTE", "PAZ SOBERANĂŤA REPĂšBLICA"
    ), AG2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), AG3 = c("00000", "00000", "00000", "00000", 
    "00000"), AH1 = c("PAZ SOBERANĂŤA REPĂšBLICA", "FIEL", "FIEL", 
    "SAE", "FIEL"), AH2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), AH3 = c("00000", "00000", "00000", 
    "00000", "00000"), AI1 = c("FIEL", "IZQP - UNIDOS - DEf", 
    "IZQP - UNIDOS - DEf", "J.U.E.X.", "IZQP - UNIDOS - DEf"), 
    AI2 = c("00000000", "00000000", "00000000", "00000000", "00000000"
    ), AI3 = c("00000", "00000", "00000", "00000", "00000"), 
    AJ1 = c("IZQP - UNIDOS - DEf", "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
    "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", "PAZ SOBERANĂŤA REPĂšBLICA", 
    "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX"), AJ2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AJ3 = c("00000", 
    "00000", "00000", "00000", "00000"), AK1 = c("EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
    "glg", "glg", "FIEL", "glg"), AK2 = c("00000000", "00000000", 
    "00000000", "00000000", "00000000"), AK3 = c("00000", "00000", 
    "00000", "00000", "00000"), AL1 = c("glg", "PIRATES.CAT / REBELDES", 
    "PIRATES.CAT / REBELDES", "glg", "PIRATES.CAT / REBELDES"
    ), AL2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), AL3 = c("00000", "00000", "00000", "00000", 
    "00000"), AM1 = c("NEX", "NEX", "NEX", "NEX", "NEX"), AM2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AM3 = c("00000", 
    "00000", "00000", "00000", "00000")), row.names = c(NA, -5L
), class = c("tbl_df", "tbl", "data.frame")) -> df
library(tidyverse)
# convert original table to long format and clean numeric data
df |> 
  pivot_longer(
    !Cod:Municipio,
    # separate column names into letter part and number
    names_pattern = '([[:alpha:]]+)([[:digit:]])',
    # collect letter part into a column called 'Rango'; leave numbers as columns
    names_to = c('Rango', '.value'),
    # convert values in columns '2' and '3' to numbers
    values_transform = list(`2` = as.numeric, `3` = as.numeric)
  ) |> 
  rename(Partido = `1`, Porcentaje = `2`, Votos = `3`) |> 
  # correct values in Porcentaje
  mutate(Porcentaje = Porcentaje / 100) -> df_long
df_long
#> # A tibble: 195 Ă— 6
#>    Cod   Municipio Rango Partido                                Porcentaje Votos
#>    <chr> <chr>     <chr> <chr>                                       <dbl> <dbl>
#>  1 007   Huelmo    A     PSOE                                         2.48  5030
#>  2 007   Huelmo    B     PP                                           0.72  1460
#>  3 007   Huelmo    C     PODEMOS                                      0.66  1338
#>  4 007   Huelmo    D     VOX                                          0.41   831
#>  5 007   Huelmo    E     Cs                                           0.21   425
#>  6 007   Huelmo    F     PH                                           0.09   182
#>  7 007   Huelmo    G     RECORTES CERO                                0.06   121
#>  8 007   Huelmo    H     JUNTS-UE                                     0.03    60
#>  9 007   Huelmo    I     CEUS                                         0.02    40
#> 10 007   Huelmo    J     AHORA REPÚBLICAS (ERC-EH BILDU-BNG-AR…       0.02    40
#> # â„ą 185 more rows
# rank parties by total votes received and arrange by Cod and Partido
df_long |> 
  # calculate total votes received by each party
  group_by(Partido) |> 
  mutate(Total = sum(Votos)) |> 
  ungroup() |> 
  # rank parties by total number of votes received in descending order
  mutate(Partido = fct_reorder(Partido, Total, .desc = T)) |> 
  # arrange table
  arrange(Cod, Partido) -> df_long_ordered
df_long_ordered
#> # A tibble: 195 Ă— 7
#>    Cod   Municipio Rango Partido                          Porcentaje Votos Total
#>    <chr> <chr>     <chr> <fct>                                 <dbl> <dbl> <dbl>
#>  1 007   Huelmo    A     PSOE                                   2.48  5030 25200
#>  2 007   Huelmo    B     PP                                     0.72  1460 10423
#>  3 007   Huelmo    C     PODEMOS                                0.66  1338  4348
#>  4 007   Huelmo    E     Cs                                     0.21   425  2422
#>  5 007   Huelmo    D     VOX                                    0.41   831  2140
#>  6 007   Huelmo    I     CEUS                                   0.02    40   908
#>  7 007   Huelmo    J     AHORA REPÚBLICAS (ERC-EH BILDU-…       0.02    40   574
#>  8 007   Huelmo    F     PH                                     0.09   182   312
#>  9 007   Huelmo    G     RECORTES CERO                          0.06   121   227
#> 10 007   Huelmo    H     JUNTS-UE                               0.03    60   200
#> # â„ą 185 more rows

(Note that the Cs and VOX parties have swapped locations because although VOX had more votes in the Huelmo municipal district, Cs had more votes if all municipal districts are taken into account.)

# prepare table for final pivot to wider table
df_long_ordered |> 
  # convert Porctentaje and Votos to values so they're kept together later
  pivot_longer(Porcentaje:Votos) |> 
  # Rango and Total vary within Municipio so need to remove to pivot wider
  select(!c(Cod, Rango, Total)) |>
  pivot_wider(
    names_from = c(Partido, name), 
    values_from = value
  )
#> # A tibble: 5 Ă— 79
#>   Municipio PSOE_Porcentaje PSOE_Votos PP_Porcentaje PP_Votos PODEMOS_Porcentaje
#>   <chr>               <dbl>      <dbl>         <dbl>    <dbl>              <dbl>
#> 1 Huelmo               2.48       5030          0.72     1460               0.66
#> 2 Busdongo             0.33       2946          0.44     3928               0.2 
#> 3 Duero                0.89       8240          0.02      185               0   
#> 4 Coin                16.4        3968          9.24     2240               2.96
#> 5 Anduva               1.48       5016          0.77     2610               0.15
#> # â„ą 73 more variables: PODEMOS_Votos <dbl>, Cs_Porcentaje <dbl>,
#> #   Cs_Votos <dbl>, VOX_Porcentaje <dbl>, VOX_Votos <dbl>,
#> #   CEUS_Porcentaje <dbl>, CEUS_Votos <dbl>,
#> #   `AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)_Porcentaje` <dbl>,
#> #   `AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)_Votos` <dbl>,
#> #   PH_Porcentaje <dbl>, PH_Votos <dbl>, `RECORTES CERO_Porcentaje` <dbl>,
#> #   `RECORTES CERO_Votos` <dbl>, `JUNTS-UE_Porcentaje` <dbl>, …

Created on 2024-05-30 with reprex v2.0.2

Full reprex
structure(list(Cod = c("007", "009", "011", "014", "016"), Municipio = c("Huelmo", 
"Busdongo", "Duero", "Coin", "Anduva"), A1 = c("PSOE", "PP", 
"PSOE", "PSOE", "PSOE"), A2 = c("00000248", "00000044", "00000089", 
"00001637", "00000148"), A3 = c("05030", "03928", "08240", "03968", 
"05016"), B1 = c("PP", "PSOE", "VOX", "PP", "PP"), B2 = c("00000072", 
"00000033", "00000002", "00000924", "00000077"), B3 = c("01460", 
"02946", "00185", "02240", "02610"), C1 = c("PODEMOS", "PODEMOS", 
"PP", "Cs", "Cs"), C2 = c("00000066", "00000020", "00000002", 
"00000386", "00000018"), C3 = c("01338", "01785", "00185", "00935", 
"00610"), D1 = c("VOX", "VOX", "Cs", "PODEMOS", "VOX"), D2 = c("00000041", 
"00000004", "00000002", "00000296", "00000015"), D3 = c("00831", 
"00357", "00185", "00717", "00508"), E1 = c("Cs", "Cs", "CEUS", 
"CEUS", "PODEMOS"), E2 = c("00000021", "00000003", "00000001", 
"00000247", "00000015"), E3 = c("00425", "00267", "00092", "00598", 
"00508"), F1 = c("PH", "CEUS", "AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", 
"AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", "FE de las JONS"
), F2 = c("00000009", "00000002", "00000001", "00000146", "00000001"
), F3 = c("00182", "00178", "00092", "00353", "00033"), G1 = c("RECORTES CERO", 
"AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", "PCPE/PCPC", 
"VOX", "IZQESP"), G2 = c("00000006", "00000001", "00000001", 
"00000107", "00000000"), G3 = c("00121", "00089", "00092", "00259", 
"00000"), H1 = c("JUNTS-UE", "PCTE", "PACMA", "JUNTS-UE", "CEUS"
), H2 = c("00000003", "00000001", "00000001", "00000058", "00000000"
), H3 = c("00060", "00089", "00092", "00140", "00000"), I1 = c("CEUS", 
"IZQESP", "FE de las JONS", "ANDALUCISTAS", "FO"), I2 = c("00000002", 
"00000000", "00000001", "00000045", "00000000"), I3 = c("00040", 
"00000", "00092", "00109", "00000"), J1 = c("AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)", 
"FO", "PH", "IZQP - UNIDOS - DEf", "AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)"
), J2 = c("00000002", "00000000", "00000001", "00000028", "00000000"
), J3 = c("00040", "00000", "00092", "00067", "00000"), K1 = c("PIRATES.CAT / REBELDES", 
"JUNTS-UE", "RECORTES CERO", "PCPE/PCPC", "JUNTS-UE"), K2 = c("00000002", 
"00000000", "00000001", "00000025", "00000000"), K3 = c("00040", 
"00000", "00092", "00060", "00000"), L1 = c("PACMA", "ANDALUCISTAS", 
"IZQESP", "PH", "ANDALUCISTAS"), L2 = c("00000001", "00000000", 
"00000000", "00000016", "00000000"), L3 = c("00020", "00000", 
"00000", "00038", "00000"), M1 = c("IZQESP", "IE", "FO", "VOLT", 
"IE"), M2 = c("00000000", "00000000", "00000000", "00000016", 
"00000000"), M3 = c("00000", "00000", "00000", "00038", "00000"
), N1 = c("FO", "ESCAĂ‘OS EN BLANCO", "JUNTS-UE", "FE de las JONS", 
"ESCAĂ‘OS EN BLANCO"), N2 = c("00000000", "00000000", "00000000", 
"00000015", "00000000"), N3 = c("00000", "00000", "00000", "00036", 
"00000"), O1 = c("ANDALUCISTAS", "CRT", "ANDALUCISTAS", "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
"CRT"), O2 = c("00000000", "00000000", "00000000", "00000013", 
"00000000"), O3 = c("00000", "00000", "00000", "00031", "00000"
), P1 = c("IE", "PFAC", "IE", "FO", "PFAC"), P2 = c("00000000", 
"00000000", "00000000", "00000011", "00000000"), P3 = c("00000", 
"00000", "00000", "00026", "00000"), Q1 = c("ESCAĂ‘OS EN BLANCO", 
"PCPE/PCPC", "ESCAĂ‘OS EN BLANCO", "PCTE", "PCTE"), Q2 = c("00000000", 
"00000000", "00000000", "00000009", "00000000"), Q3 = c("00000", 
"00000", "00000", "00021", "00000"), R1 = c("CRT", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
"CRT", "RECORTES CERO", "PCPE/PCPC"), R2 = c("00000000", "00000000", 
"00000000", "00000006", "00000000"), R3 = c("00000", "00000", 
"00000", "00014", "00000"), S1 = c("PFAC", "P-LIB", "PODEMOS", 
"PIRATES.CAT / REBELDES", "SALAMANCA-ZAMORA-LEĂ“N PREPAL"), S2 = c("00000000", 
"00000000", "00000000", "00000006", "00000000"), S3 = c("00000", 
"00000", "00000", "00014", "00000"), T1 = c("PCTE", "SUMAR", 
"PFAC", "IZQESP", "P-LIB"), T2 = c("00000000", "00000000", "00000000", 
"00000004", "00000000"), T3 = c("00000", "00000", "00000", "00009", 
"00000"), U1 = c("PCPE/PCPC", "PACMA", "PCTE", "IE", "SUMAR"), 
    U2 = c("00000000", "00000000", "00000000", "00000003", "00000000"
    ), U3 = c("00000", "00000", "00000", "00007", "00000"), V1 = c("SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
    "CREE EN EUROPA", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", "PACMA", 
    "PACMA"), V2 = c("00000000", "00000000", "00000000", "00000003", 
    "00000000"), V3 = c("00000", "00000", "00000", "00007", "00000"
    ), W1 = c("P-LIB", "PMR", "P-LIB", "ESCAĂ‘OS EN BLANCO", 
    "CREE EN EUROPA"), W2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), W3 = c("00000", "00000", "00000", 
    "00000", "00000"), X1 = c("SUMAR", "S.A.L.F", "SUMAR", "CRT", 
    "PMR"), X2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), X3 = c("00000", "00000", "00000", "00000", "00000"
    ), Y1 = c("CREE EN EUROPA", "F", "CREE EN EUROPA", "PFAC", 
    "S.A.L.F"), Y2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), Y3 = c("00000", "00000", "00000", "00000", "00000"
    ), Z1 = c("PMR", "EXISTE", "PMR", "SALAMANCA-ZAMORA-LEĂ“N PREPAL", 
    "F"), Z2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), Z3 = c("00000", "00000", "00000", "00000", "00000"
    ), AA1 = c("S.A.L.F", "FE de las JONS", "S.A.L.F", "P-LIB", 
    "EXISTE"), AA2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), AA3 = c("00000", "00000", "00000", "00000", 
    "00000"), AB1 = c("F", "SAE", "F", "SUMAR", "SAE"), AB2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AB3 = c("00000", 
    "00000", "00000", "00000", "00000"), AC1 = c("EXISTE", "J.U.E.X.", 
    "EXISTE", "CREE EN EUROPA", "J.U.E.X."), AC2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AC3 = c("00000", 
    "00000", "00000", "00000", "00000"), AD1 = c("FE de las JONS", 
    "PH", "SAE", "PMR", "PH"), AD2 = c("00000000", "00000000", 
    "00000000", "00000000", "00000000"), AD3 = c("00000", "00000", 
    "00000", "00000", "00000"), AE1 = c("SAE", "VOLT", "J.U.E.X.", 
    "S.A.L.F", "VOLT"), AE2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), AE3 = c("00000", "00000", "00000", 
    "00000", "00000"), AF1 = c("J.U.E.X.", "RECORTES CERO", "VOLT", 
    "F", "RECORTES CERO"), AF2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), AF3 = c("00000", "00000", "00000", 
    "00000", "00000"), AG1 = c("VOLT", "PAZ SOBERANĂŤA REPĂšBLICA", 
    "PAZ SOBERANĂŤA REPĂšBLICA", "EXISTE", "PAZ SOBERANĂŤA REPĂšBLICA"
    ), AG2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), AG3 = c("00000", "00000", "00000", "00000", 
    "00000"), AH1 = c("PAZ SOBERANĂŤA REPĂšBLICA", "FIEL", "FIEL", 
    "SAE", "FIEL"), AH2 = c("00000000", "00000000", "00000000", 
    "00000000", "00000000"), AH3 = c("00000", "00000", "00000", 
    "00000", "00000"), AI1 = c("FIEL", "IZQP - UNIDOS - DEf", 
    "IZQP - UNIDOS - DEf", "J.U.E.X.", "IZQP - UNIDOS - DEf"), 
    AI2 = c("00000000", "00000000", "00000000", "00000000", "00000000"
    ), AI3 = c("00000", "00000", "00000", "00000", "00000"), 
    AJ1 = c("IZQP - UNIDOS - DEf", "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
    "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", "PAZ SOBERANĂŤA REPĂšBLICA", 
    "EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX"), AJ2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AJ3 = c("00000", 
    "00000", "00000", "00000", "00000"), AK1 = c("EXTREMEĂ‘OS, Y SUBSIDIARIAMENTE EX PREX CREX", 
    "glg", "glg", "FIEL", "glg"), AK2 = c("00000000", "00000000", 
    "00000000", "00000000", "00000000"), AK3 = c("00000", "00000", 
    "00000", "00000", "00000"), AL1 = c("glg", "PIRATES.CAT / REBELDES", 
    "PIRATES.CAT / REBELDES", "glg", "PIRATES.CAT / REBELDES"
    ), AL2 = c("00000000", "00000000", "00000000", "00000000", 
    "00000000"), AL3 = c("00000", "00000", "00000", "00000", 
    "00000"), AM1 = c("NEX", "NEX", "NEX", "NEX", "NEX"), AM2 = c("00000000", 
    "00000000", "00000000", "00000000", "00000000"), AM3 = c("00000", 
    "00000", "00000", "00000", "00000")), row.names = c(NA, -5L
), class = c("tbl_df", "tbl", "data.frame")) -> df

library(tidyverse)
# convert original table to long format and clean numeric data
df |> 
  pivot_longer(
    !Cod:Municipio,
    # separate column name into letter part and number
    names_pattern = '([[:alpha:]]+)([[:digit:]])',
    # collect letter part into a column called 'Rango'; leave numbers as columns
    names_to = c('Rango', '.value'),
    # convert values in columns '2' and '3' to numbers
    values_transform = list(`2` = as.numeric, `3` = as.numeric)
) |> 
  rename(Partido = `1`, Porcentaje = `2`, Votos = `3`) |> 
  # correct values in Porcentaje
  mutate(Porcentaje = Porcentaje / 100) -> df_long

df_long
#> # A tibble: 195 Ă— 6
#>    Cod   Municipio Rango Partido                                Porcentaje Votos
#>    <chr> <chr>     <chr> <chr>                                       <dbl> <dbl>
#>  1 007   Huelmo    A     PSOE                                         2.48  5030
#>  2 007   Huelmo    B     PP                                           0.72  1460
#>  3 007   Huelmo    C     PODEMOS                                      0.66  1338
#>  4 007   Huelmo    D     VOX                                          0.41   831
#>  5 007   Huelmo    E     Cs                                           0.21   425
#>  6 007   Huelmo    F     PH                                           0.09   182
#>  7 007   Huelmo    G     RECORTES CERO                                0.06   121
#>  8 007   Huelmo    H     JUNTS-UE                                     0.03    60
#>  9 007   Huelmo    I     CEUS                                         0.02    40
#> 10 007   Huelmo    J     AHORA REPÚBLICAS (ERC-EH BILDU-BNG-AR…       0.02    40
#> # â„ą 185 more rows

# rank parties by total votes received and arrange by Cod and Partido
df_long |> 
  # calculate total votes received by each party
  group_by(Partido) |> 
  mutate(Total = sum(Votos)) |> 
  ungroup() |> 
  # rank parties by total number of votes received in descending order
  mutate(Partido = fct_reorder(Partido, Total, .desc = T)) |> 
  # arrange table
  arrange(Cod, Partido) -> df_long_ordered

df_long_ordered
#> # A tibble: 195 Ă— 7
#>    Cod   Municipio Rango Partido                          Porcentaje Votos Total
#>    <chr> <chr>     <chr> <fct>                                 <dbl> <dbl> <dbl>
#>  1 007   Huelmo    A     PSOE                                   2.48  5030 25200
#>  2 007   Huelmo    B     PP                                     0.72  1460 10423
#>  3 007   Huelmo    C     PODEMOS                                0.66  1338  4348
#>  4 007   Huelmo    E     Cs                                     0.21   425  2422
#>  5 007   Huelmo    D     VOX                                    0.41   831  2140
#>  6 007   Huelmo    I     CEUS                                   0.02    40   908
#>  7 007   Huelmo    J     AHORA REPÚBLICAS (ERC-EH BILDU-…       0.02    40   574
#>  8 007   Huelmo    F     PH                                     0.09   182   312
#>  9 007   Huelmo    G     RECORTES CERO                          0.06   121   227
#> 10 007   Huelmo    H     JUNTS-UE                               0.03    60   200
#> # â„ą 185 more rows

# prepare table for final pivot to wider table
df_long_ordered |> 
  # convert Porctentaje and Votos to values so they're kept together later
  pivot_longer(Porcentaje:Votos) |> 
  # Rango and Total vary within Municipio so need to remove to pivot wider
  select(!c(Cod, Rango, Total)) |>
  pivot_wider(
    names_from = c(Partido, name), 
    values_from = value
  )
#> # A tibble: 5 Ă— 79
#>   Municipio PSOE_Porcentaje PSOE_Votos PP_Porcentaje PP_Votos PODEMOS_Porcentaje
#>   <chr>               <dbl>      <dbl>         <dbl>    <dbl>              <dbl>
#> 1 Huelmo               2.48       5030          0.72     1460               0.66
#> 2 Busdongo             0.33       2946          0.44     3928               0.2 
#> 3 Duero                0.89       8240          0.02      185               0   
#> 4 Coin                16.4        3968          9.24     2240               2.96
#> 5 Anduva               1.48       5016          0.77     2610               0.15
#> # â„ą 73 more variables: PODEMOS_Votos <dbl>, Cs_Porcentaje <dbl>,
#> #   Cs_Votos <dbl>, VOX_Porcentaje <dbl>, VOX_Votos <dbl>,
#> #   CEUS_Porcentaje <dbl>, CEUS_Votos <dbl>,
#> #   `AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)_Porcentaje` <dbl>,
#> #   `AHORA REPÚBLICAS (ERC-EH BILDU-BNG-ARA MÉS)_Votos` <dbl>,
#> #   PH_Porcentaje <dbl>, PH_Votos <dbl>, `RECORTES CERO_Porcentaje` <dbl>,
#> #   `RECORTES CERO_Votos` <dbl>, `JUNTS-UE_Porcentaje` <dbl>, …

Created on 2024-05-30 with reprex v2.0.2

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.