This isn't too tricky to do, its just knowing which function to use!
one = c(1,2,5,6)
two = c(5,6,10,11)
common = intersect(one, two)
length(common)
intersect() returns a vector containing common values in two vectors. The length of that is therefore the number of common items.
If these vectors are columns in a data frame, it looks very similar:
dat = data.frame(
one = c(1,2,5,6),
two = c(5,6,10,11)
)
common = intersect(dat$one, dat$two)
length(common)