# Untitled

Jul 22nd, 2018
434
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. library(ggplot2)
2.
4.
6. ggplot(df, aes(x=agree, fill=gender)) +
7.   geom_bar(position="dodge") +
8.   xlab("Did the student agree?") +
9.   ylab("Number of cases") +
10.   ggtitle("Correlation between agreeing and gender")
11.
13. p <- ggplot(df, aes(y=gender, x=agree)) +
14.   geom_count(color="#add8e6", show.legend = F) +
15.   ggtitle("Yet another correlation between agreeing and gender") +
16.   ylab("Students gender") +
17.   xlab("Did the student agree?") +
18.   scale_size_continuous(range = c(11, 20))
19. p + geom_text(data = ggplot_build(p)\$data[[1]],
20.               aes(x,y,label=n))
21.
23. female_df <- subset(df, gender == "F" & wave=="third")
24. ggplot(female_df, aes(x=agree, fill=track)) +
25.   geom_bar(position="dodge") +
26.   xlab("Did the student agree?") +
27.   ylab("Number of cases") +
28.   ggtitle("Correlation between agreeing and gender", subtitle="Third wave, women")
29.
31. library(reshape2)
33. df.m <- melt(df)
34. df.m <- subset(df.m, variable!="age" & variable !="body.height" & variable != "mean")
35. ggplot(data = df.m, aes(x=variable, y=value)) +
36.   geom_boxplot() +
37.   ggtitle("Results by tests") +
38.   xlab("Test numbers") +
39.   ylab("Results")
40.
42. library(reshape2)
44. df.m <- melt(df)
45. df.m <- subset(df.m, variable!="age" & variable !="body.height" & variable != "mean")
46. ggplot(data = df.m, aes(x=variable, y=value)) +
48.   ggtitle("Results by tests", subtitle="Lines represent quantiles") +
49.   xlab("Test numbers") +
50.   ylab("Results")
51.
53. library(reshape2)
55. df.m <- melt(df)
56. df.m <- subset(df.m, variable!="age" & variable !="body.height" & variable != "mean")
57. ggplot(df.m, aes(x=ID, y=value, group=variable, col=variable)) +
58.   geom_point() +
59.   geom_line() +
60.   ggtitle("Results by tests for all subjects") +
61.   ylab("Results") +
62.   xlab("Subjects") +
63.   scale_color_discrete("Tests")
64.
66. library(reshape2)
68. df\$Means <- df\$mean
69. for(i in 1:15){
70.   df\$Medians[i] <- median(c(df\$test.1[i],df\$test.2[i],df\$test.3[i],df\$test.4[i],df\$test.5[i]))
71. }
72. df.m <- melt(df)
73. df.m <- subset(df.m, variable=="Means" | variable=="Medians")
74. ggplot(df.m, aes(x=ID, y=value, group=variable, col=variable)) +
75.   geom_point() +
76.   geom_line() +
77.   ggtitle("Means vs. medians for all subjects") +
78.   ylab("Means and meds") +
79.   xlab("Subjects") +
80.   scale_color_discrete("Measures")
RAW Paste Data