Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code to create p-value histograms of significant p-values in journal abstracts for JAMA, NEJM, BMJ, Lancet, and AJE 2000-2010
## See the paper by Jager and Leek and associated discussion
## for more information: http://biostatistics.oxfordjournals.org/content/15/1/1
## For the code to perform the analysis in that paper or to see how the p-values
## were collected see the repo: https://github.com/jtleek/swfdr
## The data for this gist are available here:
## https://github.com/jtleek/swfdr/blob/master/pvalueData.rda
## Load packages
library(ggplot2)
## Load data
load("pvalueData.rda")
## Make a data frame
pvalueData <- as.data.frame(pvalueData)
## Make pvalue data numeric
pvalueData$pvalue = as.numeric(as.vector(pvalueData$pvalue))
## Add journal names
pvalueData$journal = rownames(pvalueData)
## Subset to significant p-values
pval05 = pvalueData[pvalueData$pvalue < 0.05,]
## Make a plot
qplot(factor(journal), pvalue, data = pval05, geom = "violin",fill=journal)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment