This file contains hidden or 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
| #Long list of packages here. WDI is used to pull the data down, | |
| #plyr and reshape are used for melt/cast and ddply | |
| #tseries is used for the ADF test and could be excluded if you | |
| #weren't interest in that. ggplot2 is used to bring in | |
| #rescale() but that could be done by hand if you wanted. | |
| #maps and geosphere are used for the great circle plotting | |
| library(WDI) | |
| library(plyr) | |
| library(reshape) |
This file contains hidden or 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
| #Data recorded from a full french press at five minute intervals. Temperatures are in | |
| #Farenheit. | |
| french<- structure(list(Time = c(0L, 5L, 10L, 15L, 20L, 25L, 30L, 35L, | |
| 40L, 45L, 50L, 55L, 60L, 65L, 70L, 75L, 80L, 85L, 90L, 95L), | |
| Temp = c(201.4, 195.7, 192.1, 188.9, 185.6, 181.8, 180.1, | |
| 177.3, 174.8, 172.4, 169.8, 167.6, 165.2, 163.2, 161, 159, | |
| 156.8, 154.7, 152.9, 151.1)), .Names = c("Time", "Temp"), class = "data.frame", row.names = c(NA, -20L)) | |
| #Add another column for Kelvin | |
| french$kelvin<- (french$Temp + 459.67)*5/9 |
This file contains hidden or 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
| pop.hard<- function(endpoints) { | |
| wrap.unif<- runif(endpoints, 0, 4) | |
| pos.unif<- cut(wrap.unif, breaks=0:4,labels=FALSE) | |
| for (i in 1:4) { | |
| wrap.unif[which(pos.unif == i, arr.ind=TRUE)]<- wrap.unif[which(pos.unif == i, arr.ind=TRUE)] - (i - 1) | |
| } | |
| outer.unif<- matrix(0, endpoints, 2) | |
| outer.unif[which(pos.unif == 1, arr.ind=TRUE),]<- cbind(0, wrap.unif[which(pos.unif == 1, arr.ind=TRUE)]) | |
| outer.unif[which(pos.unif == 2, arr.ind=TRUE),]<- cbind(wrap.unif[which(pos.unif == 2, arr.ind=TRUE)], 1) | |
| outer.unif[which(pos.unif == 3, arr.ind=TRUE),]<- cbind(1, wrap.unif[which(pos.unif == 3, arr.ind=TRUE)]) |
This file contains hidden or 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(datasets) | |
| # List of states comes from http://housingtrustfundproject.org/wp-content/uploads/2011/10/2007-Housing-Trust-Fund-Progress-Report-2.pdf | |
| no.prog<- c("Alaska", "North Dakota", "South Dakota", "Wyoming", "Mississippi", "Alabama", "Virginia", "Pennsylvania", "New York") | |
| no.fund<- c("California", "Idaho", "Arkansas", "Rhode Island") | |
| funding.df<- as.data.frame(cbind(tolower(state.name), "Funded"), stringsAsFactors = FALSE) | |
| names(funding.df)<- c("region", "status") | |
| funding.df[, 2]<- factor(funding.df[, 2], levels= c("Funded", "Unfunded", "No Program"), ordered = TRUE) | |
| funding.df[state.name %in% no.fund , 2]<- "Unfunded" |
This file contains hidden or 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
| require(ggplot2); | |
| require(plyr); | |
| require(stringr); | |
| require(maps); | |
| options(stringsAsFactors = FALSE) | |
| ##Map plotting | |
| statesline <- data.frame(map("state", plot=FALSE)[c("x","y")]) | |
| usamap <- qplot(x, y, data=statesline, geom="path") | |
This file contains hidden or 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(maps) | |
| #Datasets lets me do state borders. I could just use map_data("state") but I didn't | |
| library(datasets) | |
| #Obviously this was originally a 2 column csv. I used dput() here so that someone could | |
| #recreate this easily. | |
| EAS.df<- structure(list(subregion = structure(c(3L, 12L, 10L, 5L, 18L, | |
| 47L, 76L, 66L, 32L, 73L, 15L, 35L, 52L, 28L, 48L, 25L, 70L, 30L, |
This file contains hidden or 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
| # Smarter, updated version available at | |
| # | |
| # https://github.com/Protonk/Image-Grab | |
| # | |
| # |
This file contains hidden or 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
| # Intent was to use shapiro.test() to recreate fig. 4 in | |
| # Shapiro, S. S.; Wilk, M. B. (1965). "An analysis of variance test for normality (complete samples)". Biometrika 52 (3-4): 591–611 | |
| plotPvalues <- function() { | |
| l.norm <- rnorm(5000) | |
| shap.n <- function(n) { | |
| replicate(2000, unlist(shapiro.test(sample(l.norm, n, replace = TRUE))[c(1,2)])) | |
| } | |
| shap.l <- mapply(shap.n, seq(5, 50, 5), SIMPLIFY = FALSE) | |
| plot(seq(0,1,length.out = 10), seq(0.7, 1, length.out = 10), type = "n", |
This file contains hidden or 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
| # If you don't have ggplot | |
| # run: | |
| # install.packages("ggplot2") | |
| # first | |
| library(maps) | |
| library(ggplot2) | |
| AZmap <- map_data("county", "arizona") |
This file contains hidden or 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
| /* Code to drive Freescale Semiconductor MC33887 motor driver with Arduino | |
| This example code is in the public domain. | |
| Written by Mike Gilsdorf | |
| */ | |
| void setup() { | |
| Serial.begin(9600); | |
| pinMode(2,INPUT); //sw1 |