Skip to content
Prev 277130 / 398506 Next

Combining Overlapping Data

Hi:

This doesn't sort the data by strain level, but I think it does what
you're after. It helps if strain is either a factor or character
vector in each data frame.

h <- function(x, y) {
       tbx <- table(x$strain)
       tby <- table(y$strain)
  # Select the strains who have more than one member
  # in each data frame
       mgrps <- intersect(names(tbx[tbx > 0]),
                          names(tby[tby > 0]))
  # concatenate the data with common strains
       rbind(subset(x, gp %in% mgrps),
             subset(y, gp %in% mgrps))
   }

# Result:
dc <- h(x, y)

HTH,
Dennis
On Fri, Nov 11, 2011 at 1:07 PM, kickout <kyle.kocak at gmail.com> wrote: