The solutions I gave here to a similar problem should work in your case as well:
I'm just including one option here, but take a look at the link in that other thread for more. I'm using dplyr at the end just to do some reordering of the variables (though, again, there are many ways to do this in R)
segmento_info<- data.frame(stringsAsFactors=FALSE,
ID = c(35540, 35658, 35731, 35825, 35541, 35542,
35543, 35544),
Segment_Name = c("XILTI_ARTAT", "ZAG_VBA", "ZMR_ORBIS",
"ZWN_PIREK", "VERCE_MLP.A", "VERED_BMN.A",
"VERED_WSN", "VEREV_GIMEX")
)
InfoTOChange<- data.frame(stringsAsFactors=FALSE,
ID_1 = c(35540, 35540, 35540, 35540, 35540, 35540,
35540),
ID_2 = c(35658, 35731, 35825, 35541, 35542, 35543,
35544),
Non_Possible_Conflict = c("TRUE", "TRUE", "TRUE", "FALSE", "FALSE",
"FALSE", "FALSE"),
Possible_Inicial_Conflict = c("FALSE", "FALSE", "FALSE", "TRUE", "TRUE",
"FALSE", "FALSE"),
Possible_End_Conflict = c("FALSE", "FALSE", "FALSE", "TRUE", "TRUE",
"FALSE", "FALSE")
)
InfoTOChange$Segment_Name_1 <- segmento_info[match(InfoTOChange$ID_1, segmento_info$ID), ]$Segment_Name
InfoTOChange$ID_1 <- NULL
InfoTOChange$Segment_Name_2 <- segmento_info[match(InfoTOChange$ID_2, segmento_info$ID), ]$Segment_Name
InfoTOChange$ID_2 <- NULL
dplyr::select(InfoTOChange, dplyr::starts_with("Segment"), dplyr::everything())
#> Segment_Name_1 Segment_Name_2 Non_Possible_Conflict Possible_Inicial_Conflict
#> 1 XILTI_ARTAT ZAG_VBA TRUE FALSE
#> 2 XILTI_ARTAT ZMR_ORBIS TRUE FALSE
#> 3 XILTI_ARTAT ZWN_PIREK TRUE FALSE
#> 4 XILTI_ARTAT VERCE_MLP.A FALSE TRUE
#> 5 XILTI_ARTAT VERED_BMN.A FALSE TRUE
#> 6 XILTI_ARTAT VERED_WSN FALSE FALSE
#> 7 XILTI_ARTAT VEREV_GIMEX FALSE FALSE
#> Possible_End_Conflict
#> 1 FALSE
#> 2 FALSE
#> 3 FALSE
#> 4 TRUE
#> 5 TRUE
#> 6 FALSE
#> 7 FALSE
Created on 2019-12-06 by the reprex package (v0.3.0.9001)
R is an interpreted language, so you don't need to worry about compilation!