Created
April 6, 2022 20:03
-
-
Save WillForan/43d0aa1787087de96eb0448560e62cd7 to your computer and use it in GitHub Desktop.
density plot with disparate scaling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(dplyr) | |
library(cowplot) | |
theme_set(theme_cowplot()) | |
load("ds2_long.rdata") | |
# Smith is different than the other two | |
combine_ds2_long %>% split(.$study) %>% lapply(function(x) summary(x$value)) %>% bind_rows | |
# Min. `1st Qu.` Median Mean `3rd Qu.` Max. `NA's` | |
# <table> <table> <table> <table> <table> <table> <table> | |
# 8.82e-65 1.0000e-03 3.300e-02 1.585343e-01 2.31e-01 9.94e-01 414 | |
# 6.39e-12 8.6000e-02 3.120e-01 3.788611e-01 6.43e-01 9.99e-01 221 | |
# 7.59e-165 6.9025e-14 2.285e-10 4.042874e-09 4.51e-09 3.15e-08 414 | |
density<-ggplot(combine_ds2_long) + | |
aes(x=value,colour=study,fill=study) + | |
geom_density(position="identity") + | |
facet_wrap(~study, scale="free") | |
density_zscore <- combine_ds2_long %>% group_by(study) %>% mutate(value_z=scale(value)) %>% | |
ggplot() + | |
aes(x=value_z,colour=study,fill=study) + | |
geom_density(alpha=.4) | |
plot_grid(density,density_zscore, nrow=2) |
Author
WillForan
commented
Apr 6, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment