Last active
July 16, 2017 16:13
-
-
Save cavedave/b66b961e3c0300177c43f298eb4c3e29 to your computer and use it in GitHub Desktop.
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
#Code is a copy of 'It brings me ggjoy' http://austinwehrwein.com/data-visualization/it-brings-me-ggjoy/ | |
#Data from met.ie http://www.met.ie/climate-request/ | |
dublin.raw<-read.csv('dublinairportNoHead.csv', sep=',', header=TRUE) | |
head(dublin.raw) | |
library(lubridate) | |
library(dplyr) | |
library(ggjoy) | |
library(ggplot2) | |
dublin.raw["year"] <- year(dmy(dublin.raw$date)) #make a column where the year is stored | |
dublin.raw["month"] <- month(dmy(dublin.raw$date)) #make a column where the month is stored | |
dublin.raw["day"] <- day(dmy(dublin.raw$date)) #make a column where the day is stored | |
head(dublin.raw) | |
dublin <- filter(dublin.raw, year == 2016)#only interested in one year now. Average Average might be cool later | |
#delete some columns. You dont need to do this | |
dublin$ind <- NULL | |
dublin$ind.1 <- NULL | |
dublin$igmin <- NULL | |
dublin$gmin <- NULL | |
dublin$ind.2 <- NULL | |
dublin$rain <- NULL | |
dublin$cbl <- NULL | |
dublin$wdsp <- NULL | |
dublin$ind.3 <- NULL | |
dublin$hm <- NULL | |
dublin$ind.4 <- NULL | |
dublin$ddhm <- NULL | |
dublin$ind.5 <- NULL | |
dublin$hg <- NULL | |
dublin$dos <- NULL | |
dublin$g_rad <- NULL | |
dublin$soil <- NULL | |
dublin$pe <- NULL | |
dublin$evap <- NULL | |
dublin$smd_wd <- NULL | |
dublin$smd_md <- NULL | |
dublin$smd_pd <- NULL | |
dublin <- dublin %>% mutate(average = (maxtp+mintp)/2)#make average as half way between max and min. Which it isnt. | |
mins<-min(dublin$average)#get max and min points on graph | |
maxs<-max(dublin$average) | |
dublin <- dublin %>% mutate("Average Temperature" = (maxtp+mintp)/2) | |
dublin <- dublin %>% mutate(mon =month.abb[month]) | |
head(dublin) | |
dublin$months<-factor(rev(dublin$mon),levels=rev(unique(dublin$mon))) | |
head(dublin) | |
myPlot <- ggplot(dublin,aes(x = average,y=months,height=..density..))+ | |
geom_joy(scale=3) + | |
scale_x_continuous(limits = c(mins,maxs))+ | |
theme_joy() + | |
labs(x = "Average Temperature °C")+ | |
theme(axis.title.y=element_blank(), | |
axis.ticks.y=element_blank(), | |
strip.text.y = element_text(angle = 180, hjust = 1))+ | |
labs(title='Temperatures in Dublin, Ireland', | |
subtitle='Temperatures by month for 2016 by @iamreddave') | |
ggsave(filename="Dublin.png", plot=myPlot) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment