[R] looking for setdiff equivalent on dataset

2010-07-29 Thread BaKaLeGuM
Hi everybody ! little question. I have 2 dataset TheLittleOne-data.frame(cbind(c(2,3),c(2,3))) TheBigOne-data.frame(cbind(c(1,1,2),c(1,1,2))) And I would like to obtain the TheBigOne - TheLittleOne (the row in TheBigOne not in TheLittleOne The result should be: cbind(c(1,1),c(1,1)) Have you

Re: [R] looking for setdiff equivalent on dataset

2010-07-29 Thread Hadley Wickham
Here's one way, using a function from the plyr package: TheLittleOne-data.frame(cbind(c(2,3),c(2,3))) TheBigOne-data.frame(cbind(c(1,1,2),c(1,1,2))) keys - plyr:::join.keys(TheBigOne, TheLittleOne) !(keys$x %in% keys$y) TheBigOne[!(keys$x %in% keys$y), ] Hadley On Thu, Jul 29, 2010 at 1:38

Re: [R] looking for setdiff equivalent on dataset

2010-07-29 Thread Bert Gunter
Well, here's one way that might work (explanation below): The ideas is to turn each row into a character vector and then work with the two character vectors. bigs - do.call(paste,TheBigOne) ix - which(bigs %in% setdiff(bigs,do.call(paste,TheLittleOne))) TheBigOne[ix,] However, this may not

Re: [R] looking for setdiff equivalent on dataset

2010-07-29 Thread BaKaLeGuM
perfect ! thx ( I found prob::setdiff too.. but not really what i want) 2010/7/29 Hadley Wickham had...@rice.edu Here's one way, using a function from the plyr package: TheLittleOne-data.frame(cbind(c(2,3),c(2,3))) TheBigOne-data.frame(cbind(c(1,1,2),c(1,1,2))) keys -

Re: [R] looking for setdiff equivalent on dataset

2010-07-29 Thread Henrique Dallazuanna
Try this also: TheBigOne[rowSums(!mapply(is.element, TheBigOne, TheLittleOne)) 0,] On Thu, Jul 29, 2010 at 3:38 PM, BaKaLeGuM bakale...@gmail.com wrote: Hi everybody ! little question. I have 2 dataset TheLittleOne-data.frame(cbind(c(2,3),c(2,3)))

Re: [R] looking for setdiff equivalent on dataset

2010-07-29 Thread Hadley Wickham
Well, here's one way that might work (explanation below): The ideas is to turn each row into a character vector and then work with the two character vectors. bigs - do.call(paste,TheBigOne) ix -  which(bigs %in% setdiff(bigs,do.call(paste,TheLittleOne))) TheBigOne[ix,] However, this may