Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add labs and code reusing for simplicity. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 68 additions & 105 deletions whogrowthcharts.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# weight for age
# boys
wfa.b.z <- read.csv("wfa-b-z.csv")
ggplot(wfa.b.z, aes(x=Month)) +
bwplot <- ggplot(wfa.b.z, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
Expand All @@ -33,35 +33,20 @@
geom_ribbon(aes(ymin=SD1neg, ymax=SD1), fill = "#009E73",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1, ymax=SD3), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3, ymax=28), fill = "#D55E00",alpha = 0.10)

wfa.b.z.6 <- subset(wfa.b.z, wfa.b.z$Month<=6)
ggplot(wfa.b.z.6, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
geom_line(aes(y=SD1), colour="#009E73") +
geom_line(aes(y=SD2), colour="#E69F00") +
geom_line(aes(y=SD3), colour="#D55E00") +
theme_bw() +
scale_x_continuous(expand=c(0,0),
breaks = c(0,1,2,6),
minor_breaks = seq(1, 6, 1)) +
scale_y_continuous(expand=c(0,0),
breaks = c(seq(0, 12, 1)),
minor_breaks = seq(0, 12, 0.5)) +
geom_vline(xintercept = c(1,2,6),
linetype="longdash", colour="#999999") +
ylab("Weight (Kg)") +
theme(panel.border = element_blank()) +
geom_ribbon(aes(ymin=0, ymax=SD3neg), fill = "#D55E00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1neg, ymax=SD1), fill = "#009E73",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1, ymax=SD3), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3, ymax=12), fill = "#D55E00",alpha = 0.10)


bwplot +
labs(title = "Weight for age",
subtitle = "Boys",
caption = "From 0 to 60 months")

bwplot + coord_cartesian(xlim = c(0, 6), ylim = c(0, 12)) +
labs(title = "Weight for age",
subtitle = "Boys",
caption = "From 0 to 6 months")

# girls
wfa.g.z <- read.csv("wfa-g-z.csv")
ggplot(wfa.g.z, aes(x=Month)) +
gwplot <- ggplot(wfa.g.z, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
Expand All @@ -83,37 +68,22 @@
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1neg, ymax=SD1), fill = "#009E73",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1, ymax=SD3), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3, ymax=30), fill = "#D55E00",alpha = 0.10)
geom_ribbon(aes(ymin=SD3, ymax=30), fill = "#D55E00",alpha = 0.10)

wfa.g.z.6 <- subset(wfa.g.z, wfa.g.z$Month<=6)
ggplot(wfa.g.z.6, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
geom_line(aes(y=SD1), colour="#009E73") +
geom_line(aes(y=SD2), colour="#E69F00") +
geom_line(aes(y=SD3), colour="#D55E00") +
theme_bw() +
scale_x_continuous(expand=c(0,0),
breaks = c(0,1,2,6),
minor_breaks = seq(1, 6, 1)) +
scale_y_continuous(expand=c(0,0),
breaks = c(seq(0, 14, 1)),
minor_breaks = seq(0, 14, 0.5)) +
geom_vline(xintercept = c(1,2,6),
linetype="longdash", colour="#999999") +
ylab("Weight (Kg)") +
theme(panel.border = element_blank()) +
geom_ribbon(aes(ymin=0, ymax=SD3neg), fill = "#D55E00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1neg, ymax=SD1), fill = "#009E73",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1, ymax=SD3), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3, ymax=14), fill = "#D55E00",alpha = 0.10)
gwplot +
labs(title = "Weight for age",
subtitle = "Girls",
caption = "From 0 to 60 months")

gwplot + coord_cartesian(xlim = c(0, 6), ylim = c(0, 12)) +
labs(title = "Weight for age",
subtitle = "Girls",
caption = "From 0 to 6 months")

# length for age
# boys
lfa.b.z <- read.csv("lfa-b-z.csv")
ggplot(lfa.b.z, aes(x=Month)) +
blplot <- ggplot(lfa.b.z, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
Expand All @@ -132,33 +102,19 @@
ylab("Length (cm)") +
theme(panel.border = element_blank()) +
geom_ribbon(aes(ymin=40, ymax=SD3neg), fill = "#D55E00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10)
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1neg, ymax=SD1), fill = "#009E73",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1, ymax=SD3), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3, ymax=100), fill = "#D55E00",alpha = 0.10)

blplot +
labs(title = "Lenght for age",
subtitle = "Boys",
caption = "From 0 to 24 months")

lfa.b.z.6 <- subset(lfa.b.z, lfa.b.z$Month<=6)
ggplot(lfa.b.z.6, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
geom_line(aes(y=SD1), colour="#009E73") +
geom_line(aes(y=SD2), colour="#E69F00") +
geom_line(aes(y=SD3), colour="#D55E00") +
theme_bw() +
scale_x_continuous(expand=c(0,0),
breaks = c(0,1,2,6),
minor_breaks = seq(1, 6, 1)) +
scale_y_continuous(expand=c(0,0),
breaks = c(seq(40, 90, 5)),
minor_breaks = seq(40, 90, 0.5)) +
geom_vline(xintercept = c(1,2,6),
linetype="longdash", colour="#999999") +
ylab("Length (cm)") +
theme(panel.border = element_blank()) +
geom_ribbon(aes(ymin=40, ymax=SD3neg), fill = "#D55E00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10)

# girls
lfa.g.z <- read.csv("lfa-g-z.csv")
ggplot(lfa.g.z, aes(x=Month)) +
wlplot <- ggplot(lfa.g.z, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
Expand All @@ -177,34 +133,20 @@
ylab("Length (cm)") +
theme(panel.border = element_blank()) +
geom_ribbon(aes(ymin=40, ymax=SD3neg), fill = "#D55E00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10)
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1neg, ymax=SD1), fill = "#009E73",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1, ymax=SD3), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3, ymax=100), fill = "#D55E00",alpha = 0.10)

wlplot +
labs(title = "Lenght for age",
subtitle = "Girls",
caption = "From 0 to 24 months")

lfa.g.z.6 <- subset(lfa.g.z, lfa.g.z$Month<=6)
ggplot(lfa.g.z.6, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
geom_line(aes(y=SD1), colour="#009E73") +
geom_line(aes(y=SD2), colour="#E69F00") +
geom_line(aes(y=SD3), colour="#D55E00") +
theme_bw() +
scale_x_continuous(expand=c(0,0),
breaks = c(0,1,2,6),
minor_breaks = seq(1, 6, 1)) +
scale_y_continuous(expand=c(0,0),
breaks = c(seq(40, 90, 5)),
minor_breaks = seq(40, 90, 0.5)) +
geom_vline(xintercept = c(1,2,6),
linetype="longdash", colour="#999999") +
ylab("Length (cm)") +
theme(panel.border = element_blank()) +
geom_ribbon(aes(ymin=40, ymax=SD3neg), fill = "#D55E00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10)

# height for age
# boys
hfa.b.z <- read.csv("hfa-b-z.csv")
ggplot(hfa.b.z, aes(x=Month)) +
bhplot <- ggplot(hfa.b.z, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
Expand All @@ -221,11 +163,21 @@
geom_vline(xintercept = c(24, 36, 48, 60),
linetype="longdash", colour="#999999") +
ylab("Height (cm)") +
theme(panel.border = element_blank())
theme(panel.border = element_blank()) +
geom_ribbon(aes(ymin=75, ymax=SD3neg), fill = "#D55E00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1neg, ymax=SD1), fill = "#009E73",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1, ymax=SD3), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3, ymax=130), fill = "#D55E00",alpha = 0.10)

bhplot +
labs(title = "Height for age",
subtitle = "Boys",
caption = "From 24 to 60 months")

# girls
hfa.g.z <- read.csv("hfa-g-z.csv")
ggplot(hfa.g.z, aes(x=Month)) +
ghplot <- ggplot(hfa.g.z, aes(x=Month)) +
geom_line(aes(y=SD3neg), colour="#D55E00") +
geom_line(aes(y=SD2neg), colour="#E69F00") +
geom_line(aes(y=SD1neg), colour="#009E73") +
Expand All @@ -242,4 +194,15 @@
geom_vline(xintercept = c(24, 36, 48, 60),
linetype="longdash", colour="#999999") +
ylab("Height (cm)") +
theme(panel.border = element_blank())
theme(panel.border = element_blank()) +
geom_ribbon(aes(ymin=75, ymax=SD3neg), fill = "#D55E00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3neg, ymax=SD1neg), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1neg, ymax=SD1), fill = "#009E73",alpha = 0.10) +
geom_ribbon(aes(ymin=SD1, ymax=SD3), fill = "#E69F00",alpha = 0.10) +
geom_ribbon(aes(ymin=SD3, ymax=125), fill = "#D55E00",alpha = 0.10)

ghplot +
labs(title = "Height for age",
subtitle = "Girls",
caption = "From 24 to 60 months")