Skip to content

Instantly share code, notes, and snippets.

@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 %>%
import turtle
import random
random.seed(42)
i=0
#file = open("emil.txt", "r")
#file = open("pi1000000.txt", "r")
file = open("sqrt2.txt", "r")
text=file.read()
pi = list(text)
pi = list(map(int, pi))
@cavedave
cavedave / README.md
Last active January 3, 2022 20:40
When will the Carnage end?

"This American carnage stops right here and stops right now." Donald Trump

Draw for yourself the pattern of how many people are murdered in the US each year

This code was made by Adam Pearce and the data comes from Homicide Trends in United States

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 / Martin-Quinn.r
Created November 15, 2019 19:32
Martin-Quinn scores for justices, 1937-2018. The r package ggplot2 code is very slightly modified version of https://rud.is/b/2016/06/28/making-time-rivers-in-r/ by https://twitter.com/hrbrmstr data from https://mqscores.lsa.umich.edu/measures.php This made the reddit front page in a slightl different version https://www.reddit.com/r/dataisbeaut…
```{r}
library(dplyr)
library(readr)
library(ggplot2) # devtools::install_github("hadley/ggplot2")
#library(hrbrmisc) # devtools::install_github("hrbrmstr/hrbrmisc")
library(grid)
library(scales)
library(grid)
@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))