Last active
August 29, 2015 14:09
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(tidyr) | |
library(dplyr) | |
dfs=structure(list(Sex = structure(c(1L, 2L, 1L, 1L, 1L, 2L, 1L, | |
1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, | |
1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, | |
1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, | |
1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, | |
1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 2L, 1L, 1L, | |
2L, 1L, 1L, 1L, 2L), .Label = c("Men", "Women"), class = "factor"), | |
id = c("id1", "id2", "id3", "id4", "id5", "id6", "id7", "id8", | |
"id9", "id10", "id11", "id12", "id13", "id14", "id15", "id16", | |
"id17", "id18", "id19", "id20", "id21", "id22", "id23", "id24", | |
"id25", "id26", "id27", "id28", "id29", "id30", "id31", "id32", | |
"id33", "id34", "id35", "id36", "id37", "id38", "id39", "id40", | |
"id41", "id42", "id43", "id44", "id45", "id46", "id1", "id2", | |
"id3", "id4", "id5", "id6", "id7", "id8", "id9", "id10", | |
"id11", "id12", "id13", "id14", "id15", "id16", "id17", "id18", | |
"id19", "id20", "id21", "id22", "id23", "id24", "id25", "id26", | |
"id27", "id28", "id29", "id30", "id31", "id32", "id33", "id34", | |
"id35", "id36", "id37", "id38", "id39", "id40", "id41", "id42", | |
"id43", "id44", "id45", "id46"), Measurement = structure(c(1L, | |
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, | |
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, | |
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, | |
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, | |
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, | |
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, | |
2L), .Label = c("Before", "After"), class = "factor"), Waist = c(48, | |
34, 42, 42, 60, 27.5, 40, 38, 42, 37, 44, 42, 34, 42, 49, | |
40, 36, 32, 29, 52.5, 43, 37, 35, 41, 38, 36, 52, 54, 31.49606299, | |
46, 29.5, 34, 42, 38, 34.6, 48, 33.5, 33.46456693, 34, 41, | |
41.5, 30, 38, 54, 60, 36.5, 32, 28.5, 32, 28, 42, 25.5, 31, | |
34, 33.5, 31, 35.5, 34, 32, 32, 35, 32, 28, 30, 26, 36.8, | |
39, 32.5, 33, 36, 32.5, 34, 40, 38, 29.13385827, 36, 28, | |
28, 32, 35, 31.5, 32, 31, 25.19685039, 28, 37, 36.25, 27, | |
31, 35, 35, 26), Weight = c(320, 252, 246, 300, 477, 135, | |
250, 260, 245, 220, 237, 290, 186, 250, 309, 230, 200, 132, | |
147, 296, 210, 200, 197, 254, 210, 225, 416, 390, 183, 301, | |
146, 180, 220, 197, 187, 275, 176.6, 160, 200, 206, 250.6, | |
165, 214, 341, 440, 207, 165, 172, 190, 150, 317, 132, 186, | |
190, 196, 179, 223, 200, 164, 165, 192, 168, 165, 125, 145, | |
212, 201, 168, 186, 214, 182, 207, 286, 232, 174, 248, 139, | |
141.5, 160, 177, 176, 180, 160, 120, 145, 190, 188.2, 122, | |
186, 211, 215, 125)), row.names = c(NA, -92L), .Names = c("Sex", | |
"id", "Measurement", "Waist", "Weight"), class = "data.frame") | |
p=ggplot(dfs,aes(x=Weight,y=Waist,group=id)) + | |
geom_line(alpha=.35) + | |
geom_point(alpha=.75,size=2,aes(color=Measurement)) + | |
theme(legend.position="bottom") + | |
labs(x="Weight (pounds)",y="Waist (inches)") | |
p | |
#ggsave(plot=p,file="reddit_before_after.pdf",height=6,width=10) | |
#ggsave(plot=p,file="reddit_before_after.png",height=6,width=10) | |
p=ggplot(dfs,aes(x=Weight,y=Waist,group=id)) + | |
geom_line(alpha=.35) + | |
geom_point(alpha=.75,size=2,aes(color=Measurement)) + | |
theme(legend.position="bottom") + | |
labs(x="Weight (pounds)",y="Waist (inches)") + | |
facet_grid(Sex~.) | |
p | |
#ggsave(plot=p,file="reddit_before_after_gender.pdf",height=6,width=10) | |
#ggsave(plot=p,file="reddit_before_after_gender.png",height=6,width=10) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment