Skip to content

Instantly share code, notes, and snippets.

@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 / .block
Last active March 1, 2018 15:42
comparison
license: mit
@herbps10
herbps10 / .block
Last active March 6, 2018 17:35
df
license: mit
height: 700
scrolling: yes
border: yes
@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 / 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)
@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()
@herbps10
herbps10 / .block
Created November 3, 2016 19:22
fresh block
license: mit