From e2a1df7e059e1729ef5b7db31bcdb9cff1071e26 Mon Sep 17 00:00:00 2001 From: Holger Brandl Date: Tue, 8 Nov 2016 13:53:28 +0100 Subject: [PATCH] added forcats to package list --- R/core_commons.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/core_commons.R b/R/core_commons.R index 0dc1219..3b44780 100644 --- a/R/core_commons.R +++ b/R/core_commons.R @@ -80,6 +80,7 @@ load_pack(tidyr, warn_conflicts=F) load_pack(stringr) load_pack(purrr) load_pack(readr) +load_pack(forcats) load_pack(readxl) ## supress differring build number ## needed for caching @@ -252,6 +253,10 @@ fac2char <- function(mydata, convert=names(mydata)[sapply(mydata, is.factor)]){ return(newdata) } +## convenience method to sort factor levels with decreasing frequencies +fct_revfreq = function(x) fct_infreq(x) %>% fct_rev + + ## replace R within pipe change just use ... %>% do(replaceNA(0)) %>% ... replaceNA <- function(x, withValue) { x[is.na(x)] <- withValue; x } -- GitLab