Skip to content

Instantly share code, notes, and snippets.

View Aariq's full-sized avatar
🫖

Eric R. Scott Aariq

🫖
View GitHub Profile
@Aariq
Aariq / anova-bad-Anova-good.R
Created October 1, 2021 18:53
don't use anova(), use car::Anova()
# anova() uses type I SS and unless you have only categorical predictors and
# balanced sample sizes, the order of the formula will change p-values,
# sometimes drastically!
m1 <- lm(Volume ~ Height + Girth, data = trees)
m2 <- lm(Volume ~ Girth + Height, data = trees)
anova(m1)
#> Analysis of Variance Table
#>
@Aariq
Aariq / read-multiple.R
Created February 25, 2021 14:26
Read in data spread across multiple .csv files or multiple sheets of .xlsx files.
# Read in multiple .csv files with the same structure (same column names, numbers of columns, types of data in each column) and join them into a single data frame:
library(readr)
library(purrr)
root <- "path/to/where/my/data/is/"
file_paths <- list.files(root, pattern = "*.csv", full.names = TRUE)
#set the names of the file_paths vector, here I'll just use the file names, but you can use whatever
names(file_paths) <- list.files(root, pattern = "*.csv")
@Aariq
Aariq / convex_hulls.png
Created September 5, 2018 18:38 — forked from mbedward/convex_hulls.png
Example of drawing convex hulls around grouped points in R using dplyr and ggplot.
convex_hulls.png