df <- data.frame(gene1 = c("A", "B", "C", "D", "E"),
gene2 = c("F", "B", "G", "H", "I"),
gene3 = c("J", "B", "K", "L", "E"),
gene4 = c("N", "O", "P", "Q", "R"),
gene5 = c("S", "T", "U", "V", "W"),
gene6 = c("S", "T", "U", "V", "W"),
result_gene1 = c(“positive”, "negativo", "negativo", "negativo", “positive”),
result_gene2 = c("negativo", “positive”, "negativo", "negativo", "negativo"),
result_gene3 = c("negativo", “positive”, "negativo", "negativo", "negativo"),
result_gene4 = c("negativo", "negativo", "negativo", "negativo", “positive”),
result_gene5 = c("negativo", "negativo", "negativo", "negativo", "negativo"),
result_gene6 = c("negativo", "negativo", "negativo", "negativo", "negativo"),
A1 = c(“positive”, "negativo", "negativo", "negativo", “positive”),
A2 = c("negativo", “positive”, "negativo", "negativo", "negativo"),
A3 = c("negativo", “positive”, "negativo", "negativo", "negativo"),
A4 = c("negativo", "negativo", "negativo", "negativo", “positive”),
A5 = c("negativo", "negativo", "negativo", "negativo", "negativo"),
A6 = c("negativo", "negativo", "negativo", "negativo", "negativo"))
In this dataframe example, I want to compare gene1 which is "positive" in result_gene1 with gene2 which is "positive" in result_gene2. If they are equal, I want to note this as "ok" in a new column. The gene columns form pairs such as gene3 with result_gene3, and so forth. I need a script that compares gene1 (matching the condition) to gene2, gene3, gene4, gene5, gene6, one by one. I need the comparison of all genes with each other that are "positive" in their respective "result_gene" columns. I tried a verbose approach but it did not work properly. I also tried a loop suggested by chatGPT, but it was incorrect. Do I need to select the columns I will use? Can some human help me with this issue? -