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.
This commit is contained in:
13
code/prediction/utils.R
Normal file
13
code/prediction/utils.R
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
# 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)
|
||||
}
|
||||
Reference in New Issue
Block a user