Skip to content

Instantly share code, notes, and snippets.

@cavedave
cavedave / IrelandTemp2021.r
Created July 17, 2022 10:23
Ridgeline plot (Joyplot) of temperatures at dublin Airport in 2021. Thicker means there were more days with that temperature. Using max temperature as thats how we think of it due to weather forecasts. As in yesterday was 21C means the hottest yesterday got was 21Cget data from https://www.met.ie/climate/available-data/historical-data for Dublin…
get data from https://www.met.ie/climate/available-data/historical-data
for Dublin airport
```{r}
dub<-read_csv('dly532.csv', skip=25, col_names = TRUE)
head(dub)
```
date looks like 01-jan-1942
separate it out into 3 columns
@cavedave
cavedave / Mail2013article.r
Created June 18, 2022 08:52
Looking at the actual data discussed in this 2013 articlel claiming no increase in world temperature 1998-2013 https://www.dailymail.co.uk/news/article-2425775/Climate-scientists-told-cover-fact-Earths-temperature-risen-15-years.html
#choose or open the file directly
f <- file.choose()
library(dplyr)
trust <- read.csv(f)
#trust <- read.csv("HadCRUT.csv",header=TRUE)
head(trust)
#names(trust)[names(trust) == 'Anomaly..deg.C.'] <- "Anomaly..deg.C"
#if graphing all not filtering by year
vac<-trust
vac<-trust %>%
Year Recorded
1975 49293
1980 52552
1985 38637
1988 35251
1990 23484
1993 10487
1995 7035
2000 719
2005 1979
@cavedave
cavedave / vaccine.csv
Last active November 13, 2021 20:43
European Countries Covid Vaccination Rates. Vaccine take-up, from west to east. Model this asked marginalrevolution about this tweet https://twitter.com/MacaesBruno/status/1458773133897478149
Country vaccinated long lat
Denmark 77.4 10.445 55.728
Belgium 75.2 4.39 50.86
Austria 66.5 15.3 47.97
Croatia 48.4 16.173 45.567
Albania 36.1 19.8 41.28
Belarus 29.2 27.56 53.9
Bosnia 24.4 18.41 43.86
Iceland 82.5 -21.95 64.15
Ireland 76.8 -7.063 53.208
@cavedave
cavedave / TrustVaccines
Created October 2, 2021 10:29
Do high trust countries have higher covid vaccination rates? Data from ourworldindata
trust <- read.csv("self-reported-trust-attitudes.csv",header=TRUE)
library(dplyr)
trust <- trust %>%
group_by(Entity) %>%
filter(Year == max(Year))
vac <- read.csv("owid-covid-data (1).csv",header=TRUE)
vac<-vac %>%
dplyr::select(people_vaccinated_per_hundred, location, date)
@cavedave
cavedave / vaccinewaffle.r
Created September 10, 2021 19:20
waffle graph of vaccination to ICU proportions
library(ggplot2)
library(waffle)
people <- c(`Vaccinated `=91,`Vaccinated in ICU`=1, `Unvaccinated`=7,
`Unvaccinated in ICU `=1)
waffle(people, rows=10, size=0.6,
colors=c("#44D2AC", "#E48B8B", "#B67093",
"#3A9ABD"),
title="Irish Adults",
df <-
readr::read_csv("https://projects.oregonlive.com/weather/pdx_temps.csv")
#Jun$Temp <- cut(Jun$tmax, breaks=c(50,104, Inf), labels=c("50","100+"))
Jun$Temp <- cut(Jun$tmax, breaks=c(50,60,70,80,90,100, Inf), labels=c("50","60","70","80","90","100+"))
hot <- c("#6BBCD1","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026","#FF2A24")
#hot <- c("#000000","#FF2A24")
@cavedave
cavedave / cherry.r
Created March 30, 2021 22:06
visualisation of when cherry blossoms peak in kyoto
#data from https://datagraver.com/case/kyoto-cherry-blossom-full-flower-dates#google_vignette
df <- read.csv(file ="kyoto_dates_cherryblossom2021.csv")
library(tidyverse)
df<-df %>% drop_na()
library(lubridate)
df<-df %>% select(Year, Month, Day) %>%
mutate(date2 = make_date(Year, Month, Day))
df <- df %>%
mutate(dated = yday(date2))
Count Company Percentage of global industrial greenhouse gas emissions
1 China (Coal) 14.32%
2 Saudi Arabian Oil Company (Aramco) 4.50%
3 Gazprom OAO 3.91%
4 National Iranian Oil Co 2.28%
5 ExxonMobil Corp 1.98%
6 Coal India 1.87%
7 Petroleos Mexicanos (Pemex) 1.87%
8 Russia (Coal) 1.86%
9 Royal Dutch Shell PLC 1.67%
@cavedave
cavedave / Covid.r
Last active December 8, 2020 09:56
Picture comparing Covid fatalities to large battle deaths in the US
library(tidyverse)
library(lubridate)
library(scales)
#Data
#https://ourworldindata.org/coronavirus/country/united-states?country=~USA
#war https://en.wikipedia.org/wiki/List_of_battles_with_most_United_States_military_fatalities
df<-read.csv("daily-covid-deaths-7-day.csv", header=TRUE)
#Look at US