trinker / termco

Regular Expression Counts of Terms and Substrings
Other
25 stars 5 forks source link

mutate_termco #64

Closed trinker closed 6 years ago

trinker commented 6 years ago

It's be nice to apply a function across count columns to normalize etc. Proposed ish structure:

mutate_termco <- function(model, fun = function(x) as.integer(x > 0)){

    model2 <- model %>%
        mutate_at(vars(on_campus:housing_general), fun)

    attributes(model2) <- attributes(model)
    class(model2) <- class(model)

    model <- model2

    model
}

This retains the termco class/attributes but allows for different apply all count columns some normalizing function.