Thursday, April 12, 2012

Find equal columns in data.frames

I have two data.frame objects 'x' and 'ans1', there are 500 columns in 'x' and 7 in 'ans1'
How can I find names of columns from 'x', which are equal to columns from 'ans1'?





1 comment:

  1. With %in%:

    names(x) %in% names(ans1)

    See ?match for more detail.

    ReplyDelete