Skip to content

Instantly share code, notes, and snippets.

@herbps10
herbps10 / .block
Created January 5, 2017 15:22
Violin Plot + Box Plot v3
license: mit
library(tidyverse)
library(rvest)
library(survival)
library(GGally)
library(stringr)
library(survminer)
game_data = tibble(
season = 1:33
) %>%
@herbps10
herbps10 / pfas_example.R
Last active July 13, 2017 17:14
Example of calculating median and 95th percentiles for NHANES PFAS data
devtools::install_github("silentspringinstitute/RNHANES")
library(tidyverse)
library(RNHANES)
# Data frame of variables for the analysis
variables <- tribble(
~column, ~comment_column, ~file_name, ~cycle,
"LBXPFNA", "LBDPFNAL", "PFAS_H", "2013-2014",
"LBXPFHS", "LBDPFHSL", "PFAS_H", "2013-2014",
@herbps10
herbps10 / .block
Last active March 6, 2018 17:35
df
license: mit
height: 700
scrolling: yes
border: yes
@herbps10
herbps10 / .block
Last active March 1, 2018 15:42
comparison
license: mit
@herbps10
herbps10 / nhanes_geometric_mean.R
Last active August 17, 2017 19:48
Computing geometric means of NHANES variables with 95% confidence intervals
library(survey)
library(RNHANES)
library(tidyverse)
dat <- nhanes_load_data("EPHPP_H", "2013-2014", demographics = TRUE) %>%
filter(!is.na(URXBPH), !is.na(URXBP3))
des <- nhanes_survey_design(dat, "WTSB2YR")
logmean <- svymean(~log(URXBPH), des, na.rm = TRUE)
# Downloads tweets from @dog_rates and plots
# a histogram of dog ratings.
# Used to generate picture in this tweet:
# https://twitter.com/herbps10/status/959923100468105219
library(rtweet)
library(tidyverse)
library(stringr)
library(cowplot)
library(grid)
@herbps10
herbps10 / common_squirrel.R
Created February 25, 2018 23:46
common squirrel
library(rtweet)
library(tidyverse)
library(stringr)
library(cowplot)
library(grid)
library(jpeg)
library(lubridate)
library(tidytext)
g <- rasterGrob(readJPEG("common_squirrel.jpg"), interpolate = TRUE)
@herbps10
herbps10 / isacatinthesink.R
Created February 25, 2018 23:48
isacatinthesink
library(rtweet)
library(tidyverse)
library(stringr)
library(cowplot)
library(grid)
library(jpeg)
g <- rasterGrob(readJPEG("cat.jpg"), interpolate = TRUE)
tmls <- get_timelines("isacatinthesink", n = 10)
https://images.unsplash.com/35/4fjHtYHdRlSemICxjjBu_IMG_8424.jpg?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjc3MzYzfQ
https://images.unsplash.com/photo-1497333975316-f4138c0cca11?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjc3MzYzfQ
https://images.unsplash.com/photo-1544476613-163cfbea9300?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjc3MzYzfQ
https://images.unsplash.com/flagged/photo-1536987569896-7bb4bf443404?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjc3MzYzfQ
https://images.unsplash.com/photo-1509595109082-0125495e3436?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjc3MzYzfQ
https://images.unsplash.com/photo-1558694440-03ade9215d7b?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjc3MzYzfQ
https://images.unsplash.com/photo-1558521594-1e2880f3609e?ixlib=rb-1.2.1&q=80&fm=jpg&cro