how to find elements from a list that are not present in another list in r

前端 未结 1 1889
南旧
南旧 2021-01-06 09:25

I have two lists that have the same vectors but with different length

list1 <- list(a = 1:10, b = 3:20)
list2 <- list(a = c(2,5,8), b = c(3,5,11,20))
<         


        
相关标签:
1条回答
  • 2021-01-06 10:09

    We can use

    mapply(setdiff,list1,list2)
    #$a
    #[1]  1  3  4  6  7  9 10
    
    #$b
    #[1]  4  6  7  8  9 10 12 13 14 15 16 17 18 19
    
    0 讨论(0)
提交回复
热议问题