
# Use this to check for underpopulated cells
gen.counts <- function(df, c.var){
    tapply(df[,"eid"], c.var, function(x) length(unique(x)))
}

# use this to remove underpopulated cells
restrict <- function(df, c.var, c.min){
    var.counts <- gen.counts(df, c.var)
    out.df <- df[c.var %in% names(var.counts[var.counts >
                                                   c.min]),] 
    return(out.df)
}
