1
0
Files
social-media-chapter/code/prediction/utils.R
Benjamin Mako Hill dd420c77de initial import of material for public archive into git
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.
2018-01-21 17:15:51 -08:00

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)
}