Skip to content

Instantly share code, notes, and snippets.

``` r
library(tidyverse)
iris %>%
count(Species)
#> # A tibble: 3 x 2
#> Species n
#> <fct> <int>
#> 1 setosa 50
#> 2 versicolor 50
``` r
library(tidyverse)
#> Warning: package 'forcats' was built under R version 3.5.2
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:base':
#>
#> date
library(tidyverse)
set.seed(1000)
asdpop_base <- tibble::tibble(
time1 = sample(1:100, 100, replace = F),
time2 = time1) %>%
tidyr::gather(x, y, time1:time2, factor_key = TRUE)
asdpop <- asdpop_base %>%
mutate(services = as.factor(case_when(
x == "time1" & y <= 30 ~ 1,

Keybase proof

I hereby claim:

  • I am apreshill on github.
  • I am alisonhill (https://keybase.io/alisonhill) on keybase.
  • I have a public key ASCucGQ8iaHYozuOw_4ZGI0JRFMRU-hq2paVGj_nlW35eQo

To claim this, I am signing this object:

library(tidyverse)
msleep <- msleep %>%
select(name:order)
msleep
msleep %>%
add_count(vore) %>% # n = vores
count(vore, order, n) %>% # nn = unique orders per vore
# Create a GitHub PAT
# Hint: use the usethis package
# see: http://happygitwithr.com/github-pat.html#step-by-step
library(usethis)
browse_github_pat() # takes you to browser
# Add it to .Renviron
# Hint: use the usethis package
edit_r_environ() # makes the file if not yet made- needs blank line at end!
# now copy/paste long PAT with = sign
tap 'homebrew/cask'
tap 'homebrew/cask-fonts'
tap 'homebrew/cask-versions'
tap 'homebrew/cask-drivers'
cask_args appdir: '/Applications'
# Version Control
brew 'git', args: ['with-persistent-https',
'with-curl',
@apreshill
apreshill / orly-owl-residuals
Last active July 12, 2020 21:57
Shows us why visualizing residuals from a model is important
library(broom)
library(ggplot2)
# read in the data
# others available here: http://www4.stat.ncsu.edu/~stefanski/NSF_Supported/Hidden_Images/stat_res_plots.html
owl <- read.table("http://www4.stat.ncsu.edu/~stefanski/NSF_Supported/Hidden_Images/orly_owl_files/orly_owl_Lin_4p_5_flat.txt",
header = FALSE)
# fit the linear model
fit <- lm(V1 ~ . - 1, data = owl)
@apreshill
apreshill / cdc_addm_all.csv
Last active April 1, 2016 17:30
Prevalence of ASD in the US from most recent 4 CDC ADDM surveys
site total n_asd prevalence_1000 data_source l95_1000 u95_1000 year_survey year_pub birth_cohort table for_line
Alabama 36566 174 4.8 ho 4.1 5.5 2008 2012 2000 2 1
Arizona 32601 507 15.6 eh 14.3 17 2008 2012 2000 2 1
Arkansas 4940 52 10.5 eh 8 13.8 2008 2012 2000 2 1
Colorado 7725 91 11.8 eh 9.6 14.5 2008 2012 2000 2 0
Colorado 29336 188 6.4 ho 5.6 7.4 2008 2012 2000 2 1
Florida 29366 211 7.2 ho 6.3 8.2 2008 2012 2000 2 1
Georgia 50427 601 11.9 eh 11 12.9 2008 2012 2000 2 1
Maryland 27022 336 12.4 eh 11.2 13.8 2008 2012 2000 2 1
Missouri 25668 357 13.9 ho 12.5 15.4 2008 2012 2000 2 1
county sample state name exceedances
Mobile 20 al Dauphin Island Water & Sewer 1
Monroe 23 al Excel Water System 1
Washington 95 al Tate & Lyle Sucralose, Inc. Water System 1
Coosa 18.3 al Lake Mitchell Water, Incorporated 1
Juneau City and Borough 15.5 ak Thunder Mountain Mobile Park 1
Juneau City and Borough 31 ak Hecla Greens Creek Hawk Inlet 1
Ketchikan Gateway Borough 27.7 ak Boyer Towing 1
Ketchikan Gateway Borough 32.9 ak Thorne Bay, City Of 1
Ketchikan Gateway Borough 16.2 ak Clover Pass Christian School 2