I couldn´t properly generate a reprex, hope this works. When running @andresrcs code, the error that appears is: "Error in parse(text = dbname) : :1:7: unexpected '!'
1: maps::!", when running the real data.frames where I have about 6470 rows, another error appears ("Error in exists(dbname) : variable names are limited to 10000 bytes"). When running @FJCC code, it runs but shows a wrong answer as it can be seen in the example. Then apparently none of the codes work yet.
♀
segments<- data.frame(stringsAsFactors=FALSE,
Seg_1 = c("!DHqI_*PUT", "*WHA_RBV", "ARTAT_XILTI", "!BXhV_!BXhW",
"ARTAT_XILTI", "SIN_SUNUM", "LIVDO_ULKEM", "ARTAT_XILTI",
"ARTAT_XILTI"),
Seg_2 = c("!BznO_*PUT", "!DJxO_*WHA", "PIREK_ZWN", "!CiJD_!CiJE",
"RITAG_XILTI", "!CNit_ATNOP", "LIVDO_ULKEM",
"PODAN_XIMBA", "POLON_XIMBA")
)
conflicts<- data.frame(stringsAsFactors=FALSE,
Conf_1 = c("!DHqI_*PUT", "*WHA_RBV", "ARTAT_XILTI", "!BXhV_!BXhW",
"ARTAT_XILTI", "SIN_SUNUM", "LIVDO_ULKEM"),
Conf_2 = c("!BznO_*PUT", "!DJxO_*WHA", "PIREK_ZWN", "!CiJD_!CiJE",
"RITAG_XILTI", "!CNit_ATNOP", "LIVDO_ULKEM")
)
conflicts %>%
mutate(Categorization = map(paste0(Conf_1, Conf_2, "|", Conf_2, Conf_1),
~ if_else(any(str_detect(paste0(segments$Seg_1, segments$Seg_2), pattern = .x)),
true = "FOUND",
false = "NOT FOUND")))
Found <- vector("numeric", length = nrow(segments))
for (i in 1:nrow(segments)){
Result <- which((segments[2, 1] == conflicts[,1] & segments[i, 2] == conflicts[,2]) |
(segments[i, 1] == conflicts[,2] & segments[i, 2] == conflicts[,1]))
if (length(Result) > 0) Found[i] <- Result
}
Found <- Found[Found > 0]
conflicts$CATEGORIZATION <- "NOT FOUND"
conflicts[Found, "CATEGORIZATION"] <- "FOUND"
data.frame(stringsAsFactors=FALSE,
Conf_1 = c("!DHqI_*PUT", "*WHA_RBV", "ARTAT_XILTI", "!BXhV_!BXhW",
"ARTAT_XILTI", "SIN_SUNUM", "LIVDO_ULKEM"),
Conf_2 = c("!BznO_*PUT", "!DJxO_*WHA", "PIREK_ZWN", "!CiJD_!CiJE",
"RITAG_XILTI", "!CNit_ATNOP", "LIVDO_ULKEM"),
CATEGORIZATION = c("NOT FOUND", "FOUND", "NOT FOUND", "NOT FOUND",
"NOT FOUND", "NOT FOUND", "FOUND")
)
I would really appreciate if someone could help me with this. Thanks in advance