rundat=read.csv("C:/Users/mcternan/OneDrive - California State University, Sacramento/Research Lab/rundat.csv")
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.4.4
library(reshape2)
## Warning: package 'reshape2' was built under R version 3.4.4
library(tidyr)
## Warning: package 'tidyr' was built under R version 3.4.4
rundatu=rundat[,c(1,2,52:100)]
rundatm=rundat[,c(1,101:149)]
How many students ran at all on any given day?
props=lapply(rundatu[3:51], mean)
propsdf=data.frame(props)
props_plot=melt(propsdf)
Remove occasion 19 (December 1, 2006) because it is an extreme outlier:
props_plot=props_plot[c(1:18, 20:49),]
ggplot(props_plot, aes(x=variable, y=value)) + geom_point() + expand_limits(y=c(0,1)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) +labs(x="Measurement Occasion", y="Proportion", title="Proportion of students Who Ran")
Note that the first dip occurs at time point 22, and the second dip at time point 42.For actual proportions, see below:
props_plot
## variable value
## 1 T1_u 0.4838710
## 2 T2_u 0.5096774
## 3 T3_u 0.5096774
## 4 T4_u 0.5096774
## 5 T5_u 0.5612903
## 6 T6_u 0.5677419
## 7 T7_u 0.5290323
## 8 T8_u 0.5032258
## 9 T9_u 0.5548387
## 10 T10_u 0.5419355
## 11 T11_u 0.5419355
## 12 T12_u 0.5354839
## 13 T13_u 0.5161290
## 14 T14_u 0.5290323
## 15 T15_u 0.5096774
## 16 T16_u 0.5225806
## 17 T17_u 0.4645161
## 18 T18_u 0.4193548
## 20 T20_u 0.4516129
## 21 T21_u 0.4451613
## 22 T22_u 0.4000000
## 23 T23_u 0.4064516
## 24 T24_u 0.4322581
## 25 T25_u 0.4645161
## 26 T26_u 0.4516129
## 27 T27_u 0.4193548
## 28 T28_u 0.4129032
## 29 T29_u 0.4258065
## 30 T30_u 0.4000000
## 31 T31_u 0.4645161
## 32 T32_u 0.3806452
## 33 T33_u 0.4580645
## 34 T34_u 0.4064516
## 35 T35_u 0.3935484
## 36 T36_u 0.3806452
## 37 T37_u 0.4258065
## 38 T38_u 0.4129032
## 39 T39_u 0.3806452
## 40 T40_u 0.3741935
## 41 T41_u 0.2838710
## 42 T42_u 0.2516129
## 43 T43_u 0.4129032
## 44 T44_u 0.2967742
## 45 T45_u 0.3290323
## 46 T46_u 0.2967742
## 47 T47_u 0.3806452
## 48 T48_u 0.4064516
## 49 T49_u 0.3935484
Remove the erroneous magnitude for ID 90, T49:
rundatm[90,50] = NA
rundat[90,51] = NA
rundatu[90,50] = NA
Wide to Long format for individual plots:
orig=rundat[,c(1,3:51)]
longrun=melt(orig, id="ID")
longrun=longrun[order(longrun$ID),]
Randomly select 9 individuals to plot across time:
rando = round(runif(9, 0, 155), 0)
indplot = subset(longrun, ID %in% rando)
ggplot(indplot, aes(x=variable, y=value, group=1)) + geom_line() + facet_wrap(~ID) + labs(x="Time", y="Number of Laps", title="Individual Student Running Club Trajectories") + theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())