I didn't follow your question in detail, but it sounds like the place to start is ?match and friends: ?intersect, ?setdiff, ?"%in%" ...
Cheers, Bert On Thu, May 30, 2013 at 2:28 PM, Kristi Glover <kristi.glo...@hotmail.com> wrote: > Hi R -Users > I am sorry for bothering you. I was wondering what script can work to > calculate an immigration and extinction from two tables (time 1 and time 2). > I could easily calculate them in the Excel for small data set, but I have > very big data set. so that I was wondering to use R for this calculation. But > I could not figure it out to write these logical function in R. Would you > provide me some hints? > > For example, I have these two tables > speciesTime1<-structure(list(site = 1:4, sp1 = c(0L, 1L, 1L, 0L), sp2 = c(0L, > 1L, 1L, 0L), sp3 = c(1L, 0L, 1L, 0L)), .Names = c("site", "sp1", > "sp2", "sp3"), class = "data.frame", row.names = c(NA, -4L)) > > speciesTime2<-structure(list(site = 1:4, sp1 = c(1L, 0L, 1L, 1L), sp2 = c(0L, > 1L, 1L, 1L), sp3 = c(1L, 1L, 0L, 1L)), .Names = c("site", "sp1", > "sp2", "sp3"), class = "data.frame", row.names = c(NA, -4L)) > > >From these two tables: I wanted to make the following two tables (Imm and > >Exti] > [Imm means number of "sp" present in speciesTime2, but not in speciesTime1] > imm<-structure(list(sp1 = c(1L, 0L, 0L, 1L), sp2 = c(0L, 0L, 0L, 1L > ), sp3 = c(0L, 1L, 0L, 1L), sum = c(1L, 1L, 0L, 3L)), .Names = c("sp1", > "sp2", "sp3", "sum"), class = "data.frame", row.names = c(NA, > -4L)) > > [Exti=number of "sp" absent in speciesTime2, but present in speciesTime1] > > Exti<-structure(list(sp1 = c(0L, 1L, 0L, 0L), sp2 = c(0L, 0L, 0L, 0L > ), sp3 = c(0L, 0L, 1L, 0L), sum = c(0L, 1L, 1L, 0L)), .Names = c("sp1", > "sp2", "sp3", "sum"), class = "data.frame", row.names = c(NA, > -4L)) > Thanks > KG > === > > > > > [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm ______________________________________________ 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.