I have these data:
df1 <- data.frame(matrix(, nrow=2, ncol=2))
colnames(df1) <- c("ca", "ea")
df1$ca <- c("A=C,T=G", "T=C,G=G")
df1$ea <- c("G", "T")
And I want to make a new column called "match" which gives me the letter in column "ca" that is equal to the letter in column "ea". So my output would look like this:
df1 <- data.frame(matrix(, nrow=2, ncol=2))
colnames(df1) <- c("ca", "ea")
df1$ca <- c("A=C,T=G", "T=C,G=G")
df1$ea <- c("G", "T")
df1$match <- c("T", "C")
It is tricky because in the first instance the letter I want to match on is after the "=", but in the second instance it precedes it.