This is a test streamgraph (installed from github via devtools) from some weather events data. Mostly just to show using streamgraph
load("tidy.RData")
tidydata$fullcost <- rowSums(tidydata[,5:6], na.rm=TRUE)
library(dplyr)
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
tidydata %>% group_by(tidyCategory) %>% summarise(fullcost=sum(fullcost)) -> agEvents
topsix <- as.character(head(agEvents[order(agEvents$fullcost, decreasing=TRUE),1], 6)$tidyCategory)
library(lubridate)
tidydata$BGN_DATE <- year(tidydata$BGN_DATE)
tidydata[tidydata$tidyCategory %in% topsix,] %>% group_by(tidyCategory, BGN_DATE) %>% summarise(fullcost=sum(fullcost)) -> badTimes
badTimes <- badTimes[badTimes$fullcost > 0 & !(is.na(badTimes$fullcost)) & badTimes$BGN_DATE > 1990,]
badTimes$tidyCategory <- as.character(badTimes$tidyCategory)
badTimes$fullcost <- badTimes$fullcost/1000000000
names(badTimes) <- c("Event", "Year", "Total_cost_billions")
library(streamgraph)
badTimes %>% streamgraph("Event","Total_cost_billions", "Year", scale="continuous") %>%
sg_axis_x(5, tick_format="d3.format('04d')") %>% sg_fill_brewer("PuOr") %>%
sg_legend(show=TRUE, label="Events: ")