We're creating a fresh archive because the history for our old chapter includes API keys, data files, and other material we can't share.
14 lines
408 B
R
14 lines
408 B
R
|
|
# 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)
|
|
}
|