1

I have two csv file, A and B.

I want to find the number of different column between A and B.

For example, let's assume that A contains 7, 9, 0, 0, 2 and B contains 7,8,6,0,2 ( so A and B have five column each). Then, the number of different column is 2, the second and third column.

How can I implement this on R?

storykim
  • 93
  • 2
  • 6
  • 3
    I don't understand why 5 people vote this question down without leaving a comment what the OP could improve. I see really bad first posts on SOF which do not receive five down votes. – rmuc8 Apr 05 '15 at 17:15

1 Answers1

3

You could try

indx <- colSums(A!=B) 
which(!!indx) #gets the index of different columns
# Col2 Col3 
# 2    3 
which(!indx) #gets the index of similar columns
#Col1 Col4 Col5 
# 1    4    5 
length(which(!indx) )
#[1] 3

data

A <- data.frame(Col1= c(7,2), Col2= c(9,4), Col3= c(0,5), 
      Col4= c(0,3), Col5=c(2,3))
B <- data.frame(Col1= c(7,2), Col2= c(8,4), Col3= c(6,5), 
     Col4= c(0,3), Col5=c(2,3))
akrun
  • 874,273
  • 37
  • 540
  • 662