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?Answer1:
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) ) # 3<h3>data</h3>
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))