Skip to content

Instantly share code, notes, and snippets.

@isaactpetersen
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save isaactpetersen/e70ad657feffe2dd7f39 to your computer and use it in GitHub Desktop.

Select an option

Save isaactpetersen/e70ad657feffe2dd7f39 to your computer and use it in GitHub Desktop.
#Calculate SD of fantasy points per week
sdWeeklyPts <- matrix(nrow=NROW(fantasyPts[[1]]), ncol=simulations)
for(i in 1:simulations){
sdWeeklyPts[,i] <- apply(fantasyPts[[i]], 1, function(x) sd(x, na.rm=TRUE))
}
#Calculate robust average of weekly SD
projections$weeklySD <- apply(sdWeeklyPts, 1, function(x) tryCatch(wilcox.test(x, conf.int=TRUE, na.action="na.exclude")$estimate, error=function(e) median(x, na.rm=TRUE)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment