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 work if the data frame contain calculated numeric
values which theoretically (infinite precision) are equal but are not
exactly due to finite precision. For example, try:

> 0 %in% pi/2

If this is what you have, then you have to do something fancier working
directly with the numeric values.

 Bert Gunter
Genentech Nonclinical Biostatistics





On Thu, Jul 29, 2010 at 11:38 AM, BaKaLeGuM <bakale...@gmail.com> wrote:

> 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 any idea?
>
>
>
>
> PS : this function work.. but too slow and too much complex!..
>
> diff2data<-function(data1,data2){
> afaire<-setdiff(paste(data1[,1],data1[,2]),paste(data2[,1],data2[,2]))
> afaire<-data.frame(t(data.frame(strsplit(afaire," "))))
> if (sum(dim(afaire))
>
> !=0){afaire[,1]<-as.numeric(as.character(afaire[,1]));afaire[,2]<-as.numeric(as.character(afaire[,2]))}
> return(afaire)}
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to