How can I compare two csv file in R?

后端 未结 1 1682
一生所求
一生所求 2021-01-27 01:38

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 conta

相关标签:
1条回答
  • 2021-01-27 02:00

    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))
    
    0 讨论(0)
提交回复
热议问题