Skip to content

Instantly share code, notes, and snippets.

View laurajanegraham's full-sized avatar

Laura Jane Graham laurajanegraham

View GitHub Profile
library(tidyverse)
mod_full <- lm(mpg ~ cyl + disp + hp + drat + wt + qsec, data = mtcars)
mod_g1 <- lm(mpg ~ cyl + disp + hp, data = mtcars)
mod_g2 <- lm(mpg ~ drat + wt + qsec, data = mtcars)
dat <- data.frame(full_r2 = summary(mod_full)$r.square,
g1_r2 = summary(mod_g1)$r.square,
g2_r2 = summary(mod_g2)$r.square) %>%
mutate(g1_ind = full_r2 - g2_r2,
@laurajanegraham
laurajanegraham / wind
Created November 8, 2018 16:20
Count of turbines in wind farms for Seb
library(sf)
library(tidyverse)
load("wind_test.rda")
buffer <- wind.test %>% select(ID) %>%
st_buffer(dist=1000) %>%
st_union() %>%
st_cast("POLYGON") %>%
st_sf() %>%
@laurajanegraham
laurajanegraham / gist:208df503057e9831161f05887af392f8
Created August 14, 2018 11:02
Does suppressing output save time?
f1 <- function() {
y <- system.time(x <- rnorm(10000, 0, 1))
z <- mean(x)
print(y)
print(z)
}
f2 <- function() {
y <- system.time(x <- rnorm(10000, 0, 1))
z <- mean(x)