Created
November 16, 2015 22:35
-
-
Save explodecomputer/36bf4b37cd6b8ccfde7e to your computer and use it in GitHub Desktop.
bmi in alspac
This file contains hidden or 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(reshape2) | |
library(ggplot2) | |
library(alspac) | |
b <- findVars("bmi") | |
b <- subset(b, cat2=="Clinic" & cat3 == "Child") | |
bmi <- extractVars(b) | |
c <- cor(bmi[,-c(1:3)], use="pair") | |
lab <- c(4, 8, 12, 18, 25, 31, 37, 43, 49, 61, 84, 108, 120, 132, 204) | |
colnames(c) <- round(lab/12,1) | |
rownames(c) <- round(lab/12,1) | |
clong <- melt(c) | |
ggplot(clong, aes(as.factor(Var1), as.factor(Var2))) + | |
geom_tile(aes(fill=value)) + | |
geom_text(aes(label=round(value, 2))) + | |
labs(x="Age (years)", y="Age (years)", fill="Correlation") | |
ggsave("bmi_correlations_children.pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment