This file contains 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(igraph) | |
library(plotly) | |
library(plyr) | |
library(curl) | |
G <- read.graph("dolphins.gml", format = c("gml")) | |
L <- layout_nicely(G) |
This file contains 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
#marker size | |
#need plyr loaded | |
size<-count(es$V2) | |
size<-rename(size,c("x"="V2")) | |
es<-join(es,size, by='V2', type="left") |
This file contains 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(ggthemes) | |
library(plyr) | |
library(rvest) | |
ice_cream <- read_html("http://future.aae.wisc.edu/data/annual_values/by_area/2252?tab=sales") | |
ice_table <- ice_cream %>% | |
html_nodes('table') %>% | |
html_table(fill=TRUE) |
This file contains 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
stats<-data.frame(ice_table[2]) | |
stats$Year<-as.character(stats$Year) |
This file contains 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
ggplot(stats, aes(x=Year, y=Value)) + theme_tufte(base_size=14, ticks=F) + | |
geom_bar(width=0.25, fill="gray", stat = "identity") + theme(axis.title=element_blank()) + | |
geom_hline(yintercept=seq(5, 20, 5), col="white", lwd=1) + | |
annotate("text", x = 20, y = 18, adj=1, family="serif", | |
label = c("Per Capita\n U.S. Frozen Dairy\n Product Consumption\n (Annual)")) |
This file contains 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(directlabels) | |
#plot | |
ggplot(summary, aes(x=Year, y=mean, col=Region))+geom_line(alpha=.45,size=.75)+ theme_tufte( ticks=F)+ | |
geom_vline(xintercept=advances$Year, col="light gray",alpha=.35 ,lwd=1 )+ | |
theme(legend.position="none")+ | |
ylab("Mean Life Expectancy")+ | |
geom_dl(aes(label = Region), method = list(dl.combine( "last.points"), cex = 0.6))+ | |
geom_text(aes(x=1799, label="Vaccines", y=20 ), colour="gray", angle=270)+ | |
geom_text(aes(x=1849, label="Surgical Anesthetic", y=21), colour="gray", angle=270) + |
This file contains 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(dplyr) | |
library(ggplot2) | |
library(viridis) | |
library(ggthemes) | |
#import all the files | |
temp <- list.files(pattern="*.csv") | |
alldata <- do.call(rbind, lapply(temp, function(x) read.csv(x, stringsAsFactors = FALSE))) | |
alldata$day <- strptime(alldata$starttime, format = "%m/%d/%Y") | |
alldata$day <- as.character(alldata$day) |
This file contains 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
rides.raw<-aggregate(alldata$trip_id ,by=list(alldata$day),length) |
This file contains 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
rides.raw$Group.1<-as.Date(rides.raw$Group.1,format='%m/%d/%Y') | |
rides.raw$days<-factor(weekdays(rides.raw$Group.1,T),levels = rev(c("Mon", "Tue", "Wed", "Thu","Fri", "Sat", "Sun"))) | |
rides.raw$week<-as.numeric(format(rides.raw$Group.1,"%W")) | |
rides.raw$month<-as.numeric(format(rides.raw$Group.1,"%m")) | |
rides.raw$year<-as.numeric(format(rides.raw$Group.1,"%Y")) |
This file contains 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
ggplot(rides.raw, aes(x = week, y = days, fill = x)) + | |
scale_fill_viridis(name="Divvy Rides",option = "C", limits = c(0, max(rides.raw$x))) + | |
geom_tile(color = "white", size = 0.4)+facet_wrap("year", ncol = 1) + | |
scale_x_continuous(expand = c(0, 0), breaks = seq(1, 52, length = 12), | |
labels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))+ | |
theme_tufte() |