This will do the job. Note that my data are not precisely the same as yours, but that 1A and 1B match in 3/5 cases and 2A and 2B match in 4/5 cases.
markers = data.frame(
"1A" = c("CC", "TT", "TT", "CC", "CC"),
"1B" = c("CC", "TG", "TT", "CG", "CC"),
"2A" = c("CC", "TT", "TT", "CC", "CC"),
"2B" = c("CC", "TT", "TT", "CC", "CG"),
stringsAsFactors = FALSE
)
#
concordance = sapply(seq(1, ncol(markers), 2), function(c) {
match = sum(markers[, c] == markers[, c+1]) / nrow(markers)
})
print(concordance)
The output is
> print(concordance)
[1] 0.6 0.8
This should generalise pretty well to a larger data set. You might want to put in some logic to test that your data frame has an even number of columns.