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 <- 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 PM, 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
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> http://had.co.nz/
>

        [[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