Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jbarratt/r
base: 491784df64
...
head fork: jbarratt/r
compare: dc2398c7fa
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
7,621 data/KPDX.csv
7,621 additions, 0 deletions not shown
View
7,619 data/KVNY.csv
7,619 additions, 0 deletions not shown
View
7 presentation/grokking_apache/03_grokking/02_conclusion.md
@@ -2,3 +2,10 @@
![stonestack](stonestacking.jpg)
+!SLIDE
+
+# Keep on Learning!
+
+A great starting point: [http://goo.gl/tycK0](http://jeromyanglim.blogspot.com/2009/06/learning-r-for-researchers-in.html)
+
+![qr code](qr_code.png)
View
BIN  presentation/grokking_apache/03_grokking/qr_code.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 presentation/grokking_apache/style.css
@@ -3,9 +3,9 @@ h1, h2, h3, h4, h5, h6, .slide {
}
.slide {
- background: -webkit-gradient(linear, left bottom, left top, from(#bbd), to(#fff));
+ background: -webkit-gradient(linear, left bottom, left top, from(#dadaed), to(#fff));
background-color: #eee;
- background: -moz-linear-gradient(bottom, #bbd, #fff);
+ background: -moz-linear-gradient(bottom, #dadaed, #fff);
border-top-left-radius: 20px;
-moz-border-radius-topleft: 20px;
-webkit-border-top-left-radius: 20px;
View
29 utilities/fetch_weather
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+use LWP::Simple qw(get);
+
+my $code = $ARGV[0];
+
+my ($day, $month, $year) = (localtime(time))[3,4,5];
+$month += 1;
+$year += 1900;
+
+my $uri_a = "http://www.wunderground.com/history/airport/$code";
+my $uri_b = "1/1/CustomHistory.html?dayend=$day&monthend=$month&yearend=$year&req_city=NA&req_state=NA&req_statename=NA&format=1";
+
+my %seen = ();
+
+for my $i (1991 .. $year) {
+ my $csv = get("$uri_a/$i/$uri_b");
+ for my $line (split(/\n/, $csv)) {
+ $line =~ s/<br\s+\/>//;
+ my $first = (split(/,/, $line))[0];
+ next unless defined($first);
+ if(!defined($seen{$first})) {
+ $seen{$first}++;
+ print "$line\n";
+ }
+ }
+}
View
66 weather/citydiff.r
@@ -0,0 +1,66 @@
+# load with 'source("..../citydiff.r")'
+# returns a data frame tagged by city
+library("plyr")
+
+citydiff <- function(city1_name, city1_logfile, city2_name, city2_logfile) {
+
+ first_city <- read.csv(city1_logfile);
+ second_city <- read.csv(city2_logfile);
+
+ first_city$city <- city1_name;
+ second_city$city <- city2_name;
+
+ weather <- rbind(first_city, second_city);
+ weather$city <- factor(weather$city, levels=c(city1_name, city2_name))
+
+ # drop the rows that don't have me mean temp
+ #weather <- weather[complete.cases(weather[,"Mean.TemperatureF"]),]
+
+ weather$PrecipitationIn <- as.numeric(weather$PrecipitationIn)
+
+ weather$PST <- as.Date(weather$PST, "%Y-%m-%d")
+
+ # want to bucket the data by week number so we can see trends year on year
+ weather$weeknum <- sapply(1 + as.POSIXlt(weather$PST)$yday %/% 7, function(x) { min(x, 52)})
+
+ # Also going to want to sum up by months
+ weather$month <- factor(format(weather$PST, "%B"), order=TRUE, levels=c("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"))
+
+ png(filename="overall_temp_ranges.png", height=354, width=572)
+ print(qplot(Max.TemperatureF, color=city, data = weather, geom="density"))
+ dev.off()
+
+ png(filename="temps_over_year.png", height=354, width=572)
+ print(ggplot(weather, aes(x=weeknum, Max.TemperatureF, colour=Max.TemperatureF)) + facet_grid(city~.) + geom_point(alpha=1/6, position=position_jitter(width=3)) + scale_colour_gradient(low="blue", high="red") + geom_hline(yintercept=90) + geom_hline(yintercept=60) + geom_smooth(method="loess", size=1) + scale_x_continuous(formatter=function(x) format(strptime(paste("1990 1 ", x), format="%Y %w %U"), "%B")) + xlab("Month") + ylab("Maximum Temperature (F)"))
+ dev.off()
+
+ png(filename="cloud_cover_by_week.png", height=354, width=572)
+ print(qplot(weeknum, CloudCover, data = weather, geom="smooth", color=city, span=1))
+ dev.off()
+
+ png(filename="cloud_cover_improved.png", height=354, width=572)
+ print(ggplot(weather, aes(x=weeknum, CloudCover, colour=CloudCover)) + facet_grid(city~.) + geom_point(position=position_jitter(width=0.5, height=0.5), alpha=I(1/6)) + geom_smooth(size=1) + scale_colour_gradient(low="blue", high="black") + scale_x_continuous(formatter=function(x) format(strptime(paste("1990 1 ", x), format="%Y %w %U"), "%B")) + xlab("Month") + ylab("Cloud Cover"))
+ dev.off()
+
+ # ideal day:
+ # cloud cover <= 2
+ # max temp >= 60 && <= 90
+ # find the count of those by month. (Or probability? perfect days/total days)
+ weather$ideal <- F
+ weather <- within(weather, {
+ ideal[Max.TemperatureF >= 60 & Max.TemperatureF <= 90 & CloudCover <= 4] <- T
+ })
+ weather$ideal <- as.logical(weather$ideal)
+
+ png(filename="ideal_by_month.png", height=354, width=572)
+ print(ggplot(weather, aes(x=month, fill=ideal)) + geom_histogram() + facet_grid(city~.) + opts(axis.text.x = theme_text(angle=90, size=10)))
+ dev.off()
+
+ ideal_days <- weather[weather$ideal==TRUE,]
+
+ png(filename="ideal_summary.png", height=354, width=572)
+ print(qplot(city, data=ideal_days))
+ dev.off()
+
+ return(weather)
+}

No commit comments for this range

Something went wrong with that request. Please try again.