This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# when you need to use tidyselect in a mutate function | |
# https://stackoverflow.com/questions/48353331/row-wise-operations-select-helpers-and-the-mutate-function-in-dplyr | |
tbl %>% mutate(a = select(., contains("abc"))) | |
# based on https://rpubs.com/wch/200398 | |
mtcars %>% purrrlyr::by_row(~any(is.na(.)), .collate = "rows", .to = "has_missing") | |
tibble(a=c(1, NA, 3), b=c(NA, 2, NA), c=c(NA, 5, 6)) %>% | |
mutate(pmap_int(., function(...) sum(lift_ld(is.na)(...)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#speeded up R quantile function | |
#code is based on the original quantile function {stats}: https://svn.r-project.org/R/trunk/src/library/stats/R/quantile.R | |
#This modifed function only supports the 'type 7' quantile algorithm | |
#The following features were removed (to increase perfomance) : | |
# - output quantile names | |
# - error handling such as check if x are factors, or if probs lie outside the [0-1] range | |
#this makes the speeded up function much more prone to errors, but at the same time faster: | |
# x <- runif(10000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------- | |
# ------------------ REACTIVES INSIDE FOR LOOPS --------------------- | |
# ------------------------------------------------------------------- | |
# ------------------------------------------------------------------- | |
# --- EXAMPLE 1: this works fine, because there are no reactives in - | |
# --- the for lopp -------------------------------------------------- | |
# ------------------------------------------------------------------- | |
library(shiny) |