Skip to content

Instantly share code, notes, and snippets.

View nathancday's full-sized avatar

Nathan (Nate) Day nathancday

View GitHub Profile
@nathancday
nathancday / iris_boxplots_no_outliers.R
Last active April 18, 2018 13:26
Help_for_ShStudent.R
# https://stackoverflow.com/questions/49880268/ggplot-how-to-remove-the-outliers-from-multiple-boxplots?noredirect=1#49880268
library(tidyverse)
data(iris)
iris_long <- gather(iris, "key", "val", -Species)
# with the outliers
ggplot(iris_long, aes(Species, val)) +
geom_boxplot() +
@nathancday
nathancday / split_.R
Created March 4, 2018 20:08
A tidyverse incarnation of split()
library(rlang)
library(tidyverse)
split_ <- function(data, ..., .drop = TRUE) {
vars <- ensyms(...)
vars <- map(vars, function(x) eval(x, data))
split(data, vars, drop = .drop)
}
mtcars %>% split_(cyl)