Skip to content

Instantly share code, notes, and snippets.

@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)
@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 / package-downloads.R
Last active February 25, 2018 15:15
R Package Download Graph
library(tidyverse)
log <- cranlogs::cran_downloads(packages="RNHANES", from="2016-09-28")
ggplot(log, aes(x = date, y = cumsum(count))) + geom_point()
sum(log$count)
# 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 / 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)
@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",
library(tidyverse)
library(rvest)
library(survival)
library(GGally)
library(stringr)
library(survminer)
game_data = tibble(
season = 1:33
) %>%
@herbps10
herbps10 / .block
Created January 5, 2017 15:22
Violin Plot + Box Plot v3
license: mit
@herbps10
herbps10 / twitter-bulk-add-to-list.R
Last active December 8, 2016 16:54
Twitter Bulk Add to List
#
# Adds twitter users to a twitter list in bulk
#
library(twitteR)
query <- "#EHSFEST"
screen_name <- "herbps10"
list_slug <- "ehsfest"
setup_twitter_oauth(consumer_key = "...", consumer_secret = "...")
@herbps10
herbps10 / twitter-cloud.R
Created December 7, 2016 15:43
Twitter word cloud
library(tidyverse)
library(tm)
library(SnowballC)
library(wordcloud)
library(RColorBrewer)
setup_twitter_oauth(consumer_key = "...", consumer_secret = "...")
results <- searchTwitter("#EHSFEST", n = 1000) %>%
twListToDF()