Collapse in Rstudio

I cannot find a way how to collapse a code like the one below in RStudio.

CHES14$EPG  <-case_when(CHES14$party_name== "OVP"& CHES14$cname=="aus"~ "EPP",
                        CHES14$party_name== "SPO"& CHES14$cname=="aus"~ "S&D",
                        CHES14$party_name== "FPO"& CHES14$cname=="aus"~ "ENF",
                        CHES14$party_name== "GRUNE"& CHES14$cname=="aus"~ "Greens/EFA",
                        CHES14$party_name== "NEOS"& CHES14$cname=="aus"~ "ALDE",
                        CHES14$party_name== "N-VA"& CHES14$cname=="bel"~ "ECR",
                        CHES14$party_name== "VLD"& CHES14$cname=="bel"~ "ALDE",
                        CHES14$party_name== "CD&V"& CHES14$cname=="bel"~ "EPP",
                        CHES14$party_name== "SPA"& CHES14$cname=="bel"~ "S&D",
                        CHES14$party_name== "Groen"& CHES14$cname=="bel"~ "Greens/EFA",
                        CHES14$party_name== "VB"& CHES14$cname=="bel"~ "ENF",
                        CHES14$party_name== "PS"& CHES14$cname=="bel"~ "S&D",
                        CHES14$party_name== "MR"& CHES14$cname=="bel"~ "ALDE",
                        CHES14$party_name== "ECOLO"& CHES14$cname=="bel"~ "Greens/EFA",
                        CHES14$party_name== "cdH"& CHES14$cname=="bel"~ "EPP",
                        CHES14$party_name== "CSP"& CHES14$cname=="bel"~ "EPP",
                        CHES14$party_name== "GERB"& CHES14$cname=="bul"~ "EPP",
                        CHES14$party_name== "DSB"& CHES14$cname=="bul"~ "EPP",
                        CHES14$party_name== "BSP"& CHES14$cname=="bul"~ "S&D",
                        CHES14$party_name== "BBT"& CHES14$cname=="bul"~ "ECR",
                        CHES14$party_name== "VMRO-BND"& CHES14$cname=="bul"~ "ECR",
                        CHES14$party_name== "DPS"& CHES14$cname=="bul"~ "ALDE",
                        CHES14$party_name== "HDZ"& CHES14$cname=="cro"~ "EPP",
                        CHES14$party_name== "HSS"& CHES14$cname=="cro"~ "EPP",
                        CHES14$party_name== "SDP"& CHES14$cname=="cro"~ "S&D",
                        CHES14$party_name== "HSP"& CHES14$cname=="cro"~ "ECR",
                        CHES14$party_name== "HNS"& CHES14$cname=="cro"~ "ALDE",
                        CHES14$party_name== "IDS"& CHES14$cname=="cro"~ "ALDE",
                        CHES14$party_name== "ORaH"& CHES14$cname=="cro"~ "Greens/EFA",
                        CHES14$party_name== "DISY"& CHES14$cname=="cyp"~ "EPP",
                        CHES14$party_name== "EDEK"& CHES14$cname=="cyp"~ "S&D",
                        CHES14$party_name== "DIKO"& CHES14$cname=="cyp"~ "S&D",
                        CHES14$party_name== "AKEL"& CHES14$cname=="cyp"~ "GUE/NGL",
                        CHES14$party_name== "KDU-CSL"& CHES14$cname=="cze"~ "EPP",
                        CHES14$party_name== "TOP09"& CHES14$cname=="cze"~ "EPP",
                        CHES14$party_name== "CSSD"& CHES14$cname=="cze"~ "S&D",
                        CHES14$party_name== "ODS"& CHES14$cname=="cze"~ "ECR",
                        CHES14$party_name== "ANO2011"& CHES14$cname=="cze"~ "ALDE",
                        CHES14$party_name== "KSCM"& CHES14$cname=="cze"~ "GUE/NGL",
                        CHES14$party_name== "SVOBODNI"& CHES14$cname=="cze"~ "EFDD",
                        CHES14$party_name== "KF"& CHES14$cname=="den"~ "EPP",
                        CHES14$party_name== "SD"& CHES14$cname=="den"~ "S&D",
                        CHES14$party_name== "DF"& CHES14$cname=="den"~ "ECR",
                        CHES14$party_name== "RV"& CHES14$cname=="den"~ "ALDE",
                        CHES14$party_name== "V"& CHES14$cname=="den"~ "ALDE",
                        CHES14$party_name== "FolkB"& CHES14$cname=="den"~ "GUE/NGL",
                        CHES14$party_name== "SF"& CHES14$cname=="den"~ "GREENS/EFA",
                        CHES14$party_name== "IRL"& CHES14$cname=="est"~ "EPP",
                        CHES14$party_name== "SDE"& CHES14$cname=="est"~ "S&D",
                        CHES14$party_name== "ER"& CHES14$cname=="est"~ "ALDE",
                        CHES14$party_name== "KE"& CHES14$cname=="est"~ "ALDE",
                        CHES14$party_name== "KOK"& CHES14$cname=="fin"~ "EPP",
                        CHES14$party_name== "SDP"& CHES14$cname=="fin"~ "S&D",
                        CHES14$party_name== "PS"& CHES14$cname=="fin"~ "ECR",
                        CHES14$party_name== "KESK"& CHES14$cname=="fin"~ "ALDE",
                        CHES14$party_name== "RKP/SFP"& CHES14$cname=="fin"~ "ALDE",
                        CHES14$party_name== "VAS"& CHES14$cname=="fin"~ "GUE/NGL",
                        CHES14$party_name== "VIHR"& CHES14$cname=="fin"~ "Greens/EFA",
                        CHES14$party_name== "UMP"& CHES14$cname=="fra"~ "EPP",
                        CHES14$party_name== "PS"& CHES14$cname=="fra"~ "S&D",
                        CHES14$party_name== "MODEM"& CHES14$cname=="fra"~ "ALDE",
                        CHES14$party_name== "PCF"& CHES14$cname=="fra"~ "GUE/NGL",
                        CHES14$party_name== "PG"& CHES14$cname=="fra"~ "GUE/NGL",
                        CHES14$party_name== "EELV"& CHES14$cname=="fra"~ "Greens/EFA",
                        CHES14$party_name== "FN"& CHES14$cname=="fra"~ "ENF",
                        CHES14$party_name== "CDU"& CHES14$cname=="ger"~ "EPP",
                        CHES14$party_name== "CSU"& CHES14$cname=="ger"~ "EPP",
                        CHES14$party_name== "SDP"& CHES14$cname=="ger"~ "S&D",
                        CHES14$party_name== "AfD"& CHES14$cname=="ger"~ "ECR",
                        CHES14$party_name== "FDP"& CHES14$cname=="ger"~ "ALDE",
                        CHES14$party_name== "Linke"& CHES14$cname=="ger"~ "GUE/NGL",
                        CHES14$party_name== "DieTier"& CHES14$cname=="ger"~ "GUE/NGL",
                        CHES14$party_name== "Grunen"& CHES14$cname=="ger"~ "Greens/EFA",
                        CHES14$party_name== "Piraten"& CHES14$cname=="ger"~ "Greens/EFA",
                        CHES14$party_name== "ND"& CHES14$cname=="gre"~ "EPP",
                        CHES14$party_name== "Potami"& CHES14$cname=="gre"~ "S&D",
                        CHES14$party_name== "PASOK"& CHES14$cname=="gre"~ "S&D",
                        CHES14$party_name== "ANEL"& CHES14$cname=="gre"~ "ECR",
                        CHES14$party_name== "SYRIZA"& CHES14$cname=="gre"~ "GUE/NGL",
                        CHES14$party_name== "Fidesz"& CHES14$cname=="hun"~ "EPP",
                        CHES14$party_name== "DK"& CHES14$cname=="hun"~ "S&D",
                        CHES14$party_name== "MSZP"& CHES14$cname=="hun"~ "S&D",
                        CHES14$party_name== "LMP"& CHES14$cname=="hun"~ "Greens/EFA",
                        CHES14$party_name== "FG"& CHES14$cname=="ire"~ "EPP",
                        CHES14$party_name== "FF"& CHES14$cname=="ire"~ "ECR",
                        CHES14$party_name== "SF"& CHES14$cname=="ire"~ "GUE/NGL",
                        CHES14$party_name== "FI"& CHES14$cname=="it"~ "EPP",
                        CHES14$party_name== "NCD"& CHES14$cname=="it"~ "EPP",
                        CHES14$party_name== "SVP"& CHES14$cname=="it"~ "EPP",
                        CHES14$party_name== "UDC"& CHES14$cname=="it"~ "EPP",
                        CHES14$party_name== "PD"& CHES14$cname=="it"~ "S&D",
                        CHES14$party_name== "M5S"& CHES14$cname=="it"~ "EFDD",
                        CHES14$party_name== "LN"& CHES14$cname=="it"~ "ENF",
                        CHES14$party_name== "V"& CHES14$cname=="lat"~ "EPP",
                        CHES14$party_name== "SDPS"& CHES14$cname=="lat"~ "S&D",
                        CHES14$party_name== "NA"& CHES14$cname=="lat"~ "ECR",
                        CHES14$party_name== "LKS"& CHES14$cname=="lat"~ "Greens/EFA",
                        CHES14$party_name== "TS-LKD"& CHES14$cname=="lith"~ "EPP",
                        CHES14$party_name== "LSDP"& CHES14$cname=="lith"~ "S&D",
                        CHES14$party_name== "LLRA"& CHES14$cname=="lith"~ "ECR",
                        CHES14$party_name== "LRLS"& CHES14$cname=="lith"~ "ALDE",
                        CHES14$party_name== "DP"& CHES14$cname=="lith"~ "ALDE",
                        CHES14$party_name== "LVZS"& CHES14$cname=="lith"~ "Greens/EFA",
                        CHES14$party_name== "TT"& CHES14$cname=="lith"~ "TT",
                        CHES14$party_name== "CSV"& CHES14$cname=="lux"~ "EPP",
                        CHES14$party_name== "LSAP"& CHES14$cname=="lux"~ "S&D",
                        CHES14$party_name== "DP"& CHES14$cname=="lux"~ "ALDE",
                        CHES14$party_name== "GRENG"& CHES14$cname=="lux"~ "Green/EFA",
                        CHES14$party_name== "PN"& CHES14$cname=="mal"~ "EPP",
                        CHES14$party_name== "PL"& CHES14$cname=="mal"~ "S&D",
                        CHES14$party_name== "CDA"& CHES14$cname=="net"~ "EPP",
                        CHES14$party_name== "PvdA"& CHES14$cname=="net"~ "S&D",
                        CHES14$party_name== "CU"& CHES14$cname=="net"~ "ECR",
                        CHES14$party_name== "SGP"& CHES14$cname=="net"~ "ECR",
                        CHES14$party_name== "D66"& CHES14$cname=="net"~ "ALDE",
                        CHES14$party_name== "VVD"& CHES14$cname=="net"~ "ALDE",
                        CHES14$party_name== "SP"& CHES14$cname=="net"~ "GUE/NGL",
                        CHES14$party_name== "PVDD"& CHES14$cname=="net"~ "GUE/NGL",
                        CHES14$party_name== "GL"& CHES14$cname=="net"~ "Greens/EFA",
                        CHES14$party_name== "PVV"& CHES14$cname=="net"~ "ENF",
                        CHES14$party_name== "PO"& CHES14$cname=="pol"~ "EPP",
                        CHES14$party_name== "PSL"& CHES14$cname=="pol"~ "EPP",
                        CHES14$party_name== "SLD"& CHES14$cname=="pol"~ "S&D",
                        CHES14$party_name== "PiS"& CHES14$cname=="pol"~ "ECR",
                        CHES14$party_name== "PR"& CHES14$cname=="pol"~ "ECR",
                        CHES14$party_name== "KNP"& CHES14$cname=="pol"~ "ENF",
                        CHES14$party_name== "PSD"& CHES14$cname=="por"~ "EPP",
                        CHES14$party_name== "PP"& CHES14$cname=="por"~ "EPP",
                        CHES14$party_name== "PS"& CHES14$cname=="por"~ "S&D",
                        CHES14$party_name== "MPT"& CHES14$cname=="por"~ "ALDE",
                        CHES14$party_name== "PCP"& CHES14$cname=="por"~ "PCP",
                        CHES14$party_name== "BE"& CHES14$cname=="por"~ "BE",
                        CHES14$party_name== "PNL"& CHES14$cname=="rom"~ "EPP",
                        CHES14$party_name== "PDL"& CHES14$cname=="rom"~ "EPP",
                        CHES14$party_name== "PMP"& CHES14$cname=="rom"~ "EPP",
                        CHES14$party_name== "UDMR"& CHES14$cname=="rom"~ "EPP",
                        CHES14$party_name== "PSD"& CHES14$cname=="rom"~ "S&D",
                        CHES14$party_name== "PC"& CHES14$cname=="rom"~ "S&D",
                        CHES14$party_name== "UNPR"& CHES14$cname=="rom"~ "S&D",
                        CHES14$party_name== "SDS"& CHES14$cname=="sle"~ "EPP",
                        CHES14$party_name== "NSI"& CHES14$cname=="sle"~ "EPP",
                        CHES14$party_name== "SLS"& CHES14$cname=="sle"~ "EPP",
                        CHES14$party_name== "SD"& CHES14$cname=="sle"~ "S&D",
                        CHES14$party_name== "DeSUS"& CHES14$cname=="sle"~ "ALDE",
                        CHES14$party_name== "SDKU-DS"& CHES14$cname=="slo"~ "EPP",
                        CHES14$party_name== "KDH"& CHES14$cname=="slo"~ "EPP",
                        CHES14$party_name== "MH"& CHES14$cname=="slo"~ "EPP",
                        CHES14$party_name== "SMK-MPK"& CHES14$cname=="slo"~ "EPP",
                        CHES14$party_name== "SMER-SD"& CHES14$cname=="slo"~ "S&D",
                        CHES14$party_name== "NOVA"& CHES14$cname=="slo"~ "ECR",
                        CHES14$party_name== "OLaNO"& CHES14$cname=="slo"~ "ECR",
                        CHES14$party_name== "SaS"& CHES14$cname=="slo"~ "ALDE",
                        CHES14$party_name== "PP"& CHES14$cname=="spa"~ "EPP",
                        CHES14$party_name== "PSOE"& CHES14$cname=="spa"~ "S&D",
                        CHES14$party_name== "UPyD"& CHES14$cname=="spa"~ "ALDE",
                        CHES14$party_name== "C's"& CHES14$cname=="spa"~ "ALDE",
                        CHES14$party_name== "EAJ/PNV"& CHES14$cname=="spa"~ "ALDE",
                        CHES14$party_name== "Podemos"& CHES14$cname=="spa"~ "GUE/NGL",
                        CHES14$party_name== "IU"& CHES14$cname=="spa"~ "Greens/EFA",
                        CHES14$party_name== "ICV"& CHES14$cname=="spa"~ "Greens/EFA",
                        CHES14$party_name== "ERC"& CHES14$cname=="spa"~ "Greens/EFA",
                        CHES14$party_name== "M"& CHES14$cname=="swe"~ "EPP",
                        CHES14$party_name== "KD"& CHES14$cname=="swe"~ "EPP",
                        CHES14$party_name== "S"& CHES14$cname=="swe"~ "S&D",
                        CHES14$party_name== "FI"& CHES14$cname=="swe"~ "S&D",
                        CHES14$party_name== "FP"& CHES14$cname=="swe"~ "ALDE",
                        CHES14$party_name== "C"& CHES14$cname=="swe"~ "ALDE",
                        CHES14$party_name== "V"& CHES14$cname=="swe"~ "GUE/NGL",
                        CHES14$party_name== "MP"& CHES14$cname=="swe"~ "Greens/EFA",
                        CHES14$party_name== "SD"& CHES14$cname=="swe"~ "EFDD",
                        CHES14$party_name== "LAB"& CHES14$cname=="uk"~ "S&D",
                        CHES14$party_name== "CON"& CHES14$cname=="uk"~ "ECR",
                        CHES14$party_name== "LIBDEM"& CHES14$cname=="uk"~ "ALDE",
                        CHES14$party_name== "GREEN"& CHES14$cname=="uk"~ "Greens/EFA",
                        CHES14$party_name== "SNP"& CHES14$cname=="uk"~ "Greens/EFA",
                        CHES14$party_name== "PLAID"& CHES14$cname=="uk"~ "Greens/EFA",
                        CHES14$party_name== "UKIP"& CHES14$cname=="uk"~ "EFDD"
)

Hello,

Your example doesn't make it entirely clear what you want to communicate over. I think what you're hoping to do is the following:

#Heading -------------------------------------------------
CHES14$EPG  <-case_when(CHES14$party_name== "OVP"& CHES14$cname=="aus"~ "EPP",
                        CHES14$party_name== "SPO"& CHES14$cname=="aus"~ "S&D",
                        CHES14$party_name== "FPO"& CHES14$cname=="aus"~ "ENF",
                        CHES14$party_name== "GRUNE"& CHES14$cname=="aus"~ "Greens/EFA",
                        CHES14$party_name== "NEOS"& CHES14$cname=="aus"~ "ALDE",
                        CHES14$party_name== "N-VA"& CHES14$cname=="bel"~ "ECR",
                        CHES14$party_name== "VLD"& CHES14$cname=="bel"~ "ALDE",
                        CHES14$party_name== "CD&V"& CHES14$cname=="bel"~ "EPP",
                        CHES14$party_name== "SPA"& CHES14$cname=="bel"~ "S&D",
                        CHES14$party_name== "Groen"& CHES14$cname=="bel"~ "Greens/EFA",
                        CHES14$party_name== "VB"& CHES14$cname=="bel"~ "ENF",
                        CHES14$party_name== "PS"& CHES14$cname=="bel"~ "S&D",
                        CHES14$party_name== "MR"& CHES14$cname=="bel"~ "ALDE",
                        CHES14$party_name== "ECOLO"& CHES14$cname=="bel"~ "Greens/EFA",
                        CHES14$party_name== "cdH"& CHES14$cname=="bel"~ "EPP",
                        CHES14$party_name== "CSP"& CHES14$cname=="bel"~ "EPP",
                        CHES14$party_name== "GERB"& CHES14$cname=="bul"~ "EPP",
                        CHES14$party_name== "DSB"& CHES14$cname=="bul"~ "EPP",
                        CHES14$party_name== "BSP"& CHES14$cname=="bul"~ "S&D",
                        CHES14$party_name== "BBT"& CHES14$cname=="bul"~ "ECR",
                        CHES14$party_name== "VMRO-BND"& CHES14$cname=="bul"~ "ECR",
                        CHES14$party_name== "DPS"& CHES14$cname=="bul"~ "ALDE",
                        CHES14$party_name== "HDZ"& CHES14$cname=="cro"~ "EPP",
                        CHES14$party_name== "HSS"& CHES14$cname=="cro"~ "EPP",
                        CHES14$party_name== "SDP"& CHES14$cname=="cro"~ "S&D",
                        CHES14$party_name== "HSP"& CHES14$cname=="cro"~ "ECR",
                        CHES14$party_name== "HNS"& CHES14$cname=="cro"~ "ALDE",
                        CHES14$party_name== "IDS"& CHES14$cname=="cro"~ "ALDE",
                        CHES14$party_name== "ORaH"& CHES14$cname=="cro"~ "Greens/EFA",
                        CHES14$party_name== "DISY"& CHES14$cname=="cyp"~ "EPP",
                        CHES14$party_name== "EDEK"& CHES14$cname=="cyp"~ "S&D",
                        CHES14$party_name== "DIKO"& CHES14$cname=="cyp"~ "S&D",
                        CHES14$party_name== "AKEL"& CHES14$cname=="cyp"~ "GUE/NGL",
                        CHES14$party_name== "KDU-CSL"& CHES14$cname=="cze"~ "EPP",
                        CHES14$party_name== "TOP09"& CHES14$cname=="cze"~ "EPP",
                        CHES14$party_name== "CSSD"& CHES14$cname=="cze"~ "S&D",
                        CHES14$party_name== "ODS"& CHES14$cname=="cze"~ "ECR",
                        CHES14$party_name== "ANO2011"& CHES14$cname=="cze"~ "ALDE",
                        CHES14$party_name== "KSCM"& CHES14$cname=="cze"~ "GUE/NGL",
                        CHES14$party_name== "SVOBODNI"& CHES14$cname=="cze"~ "EFDD",
                        CHES14$party_name== "KF"& CHES14$cname=="den"~ "EPP",
                        CHES14$party_name== "SD"& CHES14$cname=="den"~ "S&D",
                        CHES14$party_name== "DF"& CHES14$cname=="den"~ "ECR",
                        CHES14$party_name== "RV"& CHES14$cname=="den"~ "ALDE",
                        CHES14$party_name== "V"& CHES14$cname=="den"~ "ALDE",
                        CHES14$party_name== "FolkB"& CHES14$cname=="den"~ "GUE/NGL",
                        CHES14$party_name== "SF"& CHES14$cname=="den"~ "GREENS/EFA",
                        CHES14$party_name== "IRL"& CHES14$cname=="est"~ "EPP",
                        CHES14$party_name== "SDE"& CHES14$cname=="est"~ "S&D",
                        CHES14$party_name== "ER"& CHES14$cname=="est"~ "ALDE",
                        CHES14$party_name== "KE"& CHES14$cname=="est"~ "ALDE",
                        CHES14$party_name== "KOK"& CHES14$cname=="fin"~ "EPP",
                        CHES14$party_name== "SDP"& CHES14$cname=="fin"~ "S&D",
                        CHES14$party_name== "PS"& CHES14$cname=="fin"~ "ECR",
                        CHES14$party_name== "KESK"& CHES14$cname=="fin"~ "ALDE",
                        CHES14$party_name== "RKP/SFP"& CHES14$cname=="fin"~ "ALDE",
                        CHES14$party_name== "VAS"& CHES14$cname=="fin"~ "GUE/NGL",
                        CHES14$party_name== "VIHR"& CHES14$cname=="fin"~ "Greens/EFA",
                        CHES14$party_name== "UMP"& CHES14$cname=="fra"~ "EPP",
                        CHES14$party_name== "PS"& CHES14$cname=="fra"~ "S&D",
                        CHES14$party_name== "MODEM"& CHES14$cname=="fra"~ "ALDE",
                        CHES14$party_name== "PCF"& CHES14$cname=="fra"~ "GUE/NGL",
                        CHES14$party_name== "PG"& CHES14$cname=="fra"~ "GUE/NGL",
                        CHES14$party_name== "EELV"& CHES14$cname=="fra"~ "Greens/EFA",
                        CHES14$party_name== "FN"& CHES14$cname=="fra"~ "ENF",
                        CHES14$party_name== "CDU"& CHES14$cname=="ger"~ "EPP",
                        CHES14$party_name== "CSU"& CHES14$cname=="ger"~ "EPP",
                        CHES14$party_name== "SDP"& CHES14$cname=="ger"~ "S&D",
                        CHES14$party_name== "AfD"& CHES14$cname=="ger"~ "ECR",
                        CHES14$party_name== "FDP"& CHES14$cname=="ger"~ "ALDE",
                        CHES14$party_name== "Linke"& CHES14$cname=="ger"~ "GUE/NGL",
                        CHES14$party_name== "DieTier"& CHES14$cname=="ger"~ "GUE/NGL",
                        CHES14$party_name== "Grunen"& CHES14$cname=="ger"~ "Greens/EFA",
                        CHES14$party_name== "Piraten"& CHES14$cname=="ger"~ "Greens/EFA",
                        CHES14$party_name== "ND"& CHES14$cname=="gre"~ "EPP",
                        CHES14$party_name== "Potami"& CHES14$cname=="gre"~ "S&D",
                        CHES14$party_name== "PASOK"& CHES14$cname=="gre"~ "S&D",
                        CHES14$party_name== "ANEL"& CHES14$cname=="gre"~ "ECR",
                        CHES14$party_name== "SYRIZA"& CHES14$cname=="gre"~ "GUE/NGL",
                        CHES14$party_name== "Fidesz"& CHES14$cname=="hun"~ "EPP",
                        CHES14$party_name== "DK"& CHES14$cname=="hun"~ "S&D",
                        CHES14$party_name== "MSZP"& CHES14$cname=="hun"~ "S&D",
                        CHES14$party_name== "LMP"& CHES14$cname=="hun"~ "Greens/EFA",
                        CHES14$party_name== "FG"& CHES14$cname=="ire"~ "EPP",
                        CHES14$party_name== "FF"& CHES14$cname=="ire"~ "ECR",
                        CHES14$party_name== "SF"& CHES14$cname=="ire"~ "GUE/NGL",
                        CHES14$party_name== "FI"& CHES14$cname=="it"~ "EPP",
                        CHES14$party_name== "NCD"& CHES14$cname=="it"~ "EPP",
                        CHES14$party_name== "SVP"& CHES14$cname=="it"~ "EPP",
                        CHES14$party_name== "UDC"& CHES14$cname=="it"~ "EPP",
                        CHES14$party_name== "PD"& CHES14$cname=="it"~ "S&D",
                        CHES14$party_name== "M5S"& CHES14$cname=="it"~ "EFDD",
                        CHES14$party_name== "LN"& CHES14$cname=="it"~ "ENF",
                        CHES14$party_name== "V"& CHES14$cname=="lat"~ "EPP",
                        CHES14$party_name== "SDPS"& CHES14$cname=="lat"~ "S&D",
                        CHES14$party_name== "NA"& CHES14$cname=="lat"~ "ECR",
                        CHES14$party_name== "LKS"& CHES14$cname=="lat"~ "Greens/EFA",
                        CHES14$party_name== "TS-LKD"& CHES14$cname=="lith"~ "EPP",
                        CHES14$party_name== "LSDP"& CHES14$cname=="lith"~ "S&D",
                        CHES14$party_name== "LLRA"& CHES14$cname=="lith"~ "ECR",
                        CHES14$party_name== "LRLS"& CHES14$cname=="lith"~ "ALDE",
                        CHES14$party_name== "DP"& CHES14$cname=="lith"~ "ALDE",
                        CHES14$party_name== "LVZS"& CHES14$cname=="lith"~ "Greens/EFA",
                        CHES14$party_name== "TT"& CHES14$cname=="lith"~ "TT",
                        CHES14$party_name== "CSV"& CHES14$cname=="lux"~ "EPP",
                        CHES14$party_name== "LSAP"& CHES14$cname=="lux"~ "S&D",
                        CHES14$party_name== "DP"& CHES14$cname=="lux"~ "ALDE",
                        CHES14$party_name== "GRENG"& CHES14$cname=="lux"~ "Green/EFA",
                        CHES14$party_name== "PN"& CHES14$cname=="mal"~ "EPP",
                        CHES14$party_name== "PL"& CHES14$cname=="mal"~ "S&D",
                        CHES14$party_name== "CDA"& CHES14$cname=="net"~ "EPP",
                        CHES14$party_name== "PvdA"& CHES14$cname=="net"~ "S&D",
                        CHES14$party_name== "CU"& CHES14$cname=="net"~ "ECR",
                        CHES14$party_name== "SGP"& CHES14$cname=="net"~ "ECR",
                        CHES14$party_name== "D66"& CHES14$cname=="net"~ "ALDE",
                        CHES14$party_name== "VVD"& CHES14$cname=="net"~ "ALDE",
                        CHES14$party_name== "SP"& CHES14$cname=="net"~ "GUE/NGL",
                        CHES14$party_name== "PVDD"& CHES14$cname=="net"~ "GUE/NGL",
                        CHES14$party_name== "GL"& CHES14$cname=="net"~ "Greens/EFA",
                        CHES14$party_name== "PVV"& CHES14$cname=="net"~ "ENF",
                        CHES14$party_name== "PO"& CHES14$cname=="pol"~ "EPP",
                        CHES14$party_name== "PSL"& CHES14$cname=="pol"~ "EPP",
                        CHES14$party_name== "SLD"& CHES14$cname=="pol"~ "S&D",
                        CHES14$party_name== "PiS"& CHES14$cname=="pol"~ "ECR",
                        CHES14$party_name== "PR"& CHES14$cname=="pol"~ "ECR",
                        CHES14$party_name== "KNP"& CHES14$cname=="pol"~ "ENF",
                        CHES14$party_name== "PSD"& CHES14$cname=="por"~ "EPP",
                        CHES14$party_name== "PP"& CHES14$cname=="por"~ "EPP",
                        CHES14$party_name== "PS"& CHES14$cname=="por"~ "S&D",
                        CHES14$party_name== "MPT"& CHES14$cname=="por"~ "ALDE",
                        CHES14$party_name== "PCP"& CHES14$cname=="por"~ "PCP",
                        CHES14$party_name== "BE"& CHES14$cname=="por"~ "BE",
                        CHES14$party_name== "PNL"& CHES14$cname=="rom"~ "EPP",
                        CHES14$party_name== "PDL"& CHES14$cname=="rom"~ "EPP",
                        CHES14$party_name== "PMP"& CHES14$cname=="rom"~ "EPP",
                        CHES14$party_name== "UDMR"& CHES14$cname=="rom"~ "EPP",
                        CHES14$party_name== "PSD"& CHES14$cname=="rom"~ "S&D",
                        CHES14$party_name== "PC"& CHES14$cname=="rom"~ "S&D",
                        CHES14$party_name== "UNPR"& CHES14$cname=="rom"~ "S&D",
                        CHES14$party_name== "SDS"& CHES14$cname=="sle"~ "EPP",
                        CHES14$party_name== "NSI"& CHES14$cname=="sle"~ "EPP",
                        CHES14$party_name== "SLS"& CHES14$cname=="sle"~ "EPP",
                        CHES14$party_name== "SD"& CHES14$cname=="sle"~ "S&D",
                        CHES14$party_name== "DeSUS"& CHES14$cname=="sle"~ "ALDE",
                        CHES14$party_name== "SDKU-DS"& CHES14$cname=="slo"~ "EPP",
                        CHES14$party_name== "KDH"& CHES14$cname=="slo"~ "EPP",
                        CHES14$party_name== "MH"& CHES14$cname=="slo"~ "EPP",
                        CHES14$party_name== "SMK-MPK"& CHES14$cname=="slo"~ "EPP",
                        CHES14$party_name== "SMER-SD"& CHES14$cname=="slo"~ "S&D",
                        CHES14$party_name== "NOVA"& CHES14$cname=="slo"~ "ECR",
                        CHES14$party_name== "OLaNO"& CHES14$cname=="slo"~ "ECR",
                        CHES14$party_name== "SaS"& CHES14$cname=="slo"~ "ALDE",
                        CHES14$party_name== "PP"& CHES14$cname=="spa"~ "EPP",
                        CHES14$party_name== "PSOE"& CHES14$cname=="spa"~ "S&D",
                        CHES14$party_name== "UPyD"& CHES14$cname=="spa"~ "ALDE",
                        CHES14$party_name== "C's"& CHES14$cname=="spa"~ "ALDE",
                        CHES14$party_name== "EAJ/PNV"& CHES14$cname=="spa"~ "ALDE",
                        CHES14$party_name== "Podemos"& CHES14$cname=="spa"~ "GUE/NGL",
                        CHES14$party_name== "IU"& CHES14$cname=="spa"~ "Greens/EFA",
                        CHES14$party_name== "ICV"& CHES14$cname=="spa"~ "Greens/EFA",
                        CHES14$party_name== "ERC"& CHES14$cname=="spa"~ "Greens/EFA",
                        CHES14$party_name== "M"& CHES14$cname=="swe"~ "EPP",
                        CHES14$party_name== "KD"& CHES14$cname=="swe"~ "EPP",
                        CHES14$party_name== "S"& CHES14$cname=="swe"~ "S&D",
                        CHES14$party_name== "FI"& CHES14$cname=="swe"~ "S&D",
                        CHES14$party_name== "FP"& CHES14$cname=="swe"~ "ALDE",
                        CHES14$party_name== "C"& CHES14$cname=="swe"~ "ALDE",
                        CHES14$party_name== "V"& CHES14$cname=="swe"~ "GUE/NGL",
                        CHES14$party_name== "MP"& CHES14$cname=="swe"~ "Greens/EFA",
                        CHES14$party_name== "SD"& CHES14$cname=="swe"~ "EFDD",
                        CHES14$party_name== "LAB"& CHES14$cname=="uk"~ "S&D",
                        CHES14$party_name== "CON"& CHES14$cname=="uk"~ "ECR",
                        CHES14$party_name== "LIBDEM"& CHES14$cname=="uk"~ "ALDE",
                        CHES14$party_name== "GREEN"& CHES14$cname=="uk"~ "Greens/EFA",
                        CHES14$party_name== "SNP"& CHES14$cname=="uk"~ "Greens/EFA",
                        CHES14$party_name== "PLAID"& CHES14$cname=="uk"~ "Greens/EFA",
                        CHES14$party_name== "UKIP"& CHES14$cname=="uk"~ "EFDD"
)

By adding the heading above your code you can collapse this whole block by clicking on the little arrow at the line number. Is this what you had in mind?

2 Likes

Most welcome :slight_smile: It will collapse your code until it finds the next heading and then stop there. In R studio you're able to press ctrl + shift + r which does a insert code section where you're able to give it a name for it and it will add the heading in for you.

Typically with a lot of code it is best practice to have several headings in just to organise and make it clear.

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

Thank you! How do I denote the end of a collapse?