Skip to content

Instantly share code, notes, and snippets.

@hobbes7878
Last active March 31, 2016 17:53
Show Gist options
  • Save hobbes7878/27d2ddf5d42230d63684aaee5a33feef to your computer and use it in GitHub Desktop.
Save hobbes7878/27d2ddf5d42230d63684aaee5a33feef to your computer and use it in GitHub Desktop.
library(RPostgreSQL)
library(dplyr)
library(lazyeval)
library(userfriendlyscience)
# DB Connections
partd <- tbl(src_postgres(dbname = "propublica", user="postgres"), "partd")
# Change specialty filter
state_p_brand <- partd %>% filter(address_state == 'TX', specialty == 'Cardiovascular Disease') %>% select(p_brand, total_amount) %>% mutate(
group = if(total_amount == 0)
'$0'
else if(total_amount > 0 & total_amount < 100)
'<$100'
else if(total_amount >= 100 & total_amount < 500)
'$100<$500'
else if(total_amount >= 500 & total_amount < 1000)
'$500<$1000'
else if(total_amount >= 1000 & total_amount < 5000)
'$1000<$5000'
else if(total_amount >= 5000)
'>=$5000'
) %>% collect()
fit <- aov(p_brand ~ group, data=state_p_brand)
oneway(state_p_brand$p_brand, state_p_brand$group, posthoc="games-howell", means=TRUE, fullDescribe=TRUE, levene=FALSE,
plot=FALSE, digits=2, pvalueDigits=3, t=FALSE, conf.level=.95)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment