View covid_cases_UK_LAs.csv
area_name | per_week_per_100k | pop | |
---|---|---|---|
Aragon | 194 | 1344184 | |
Navarra | 154 | 633017 | |
Catalonia | 921 | 7463471 | |
Basque Country | 136 | 2179532 | |
La Rioja | 12 | 319939 | |
Madrid | 229 | 6373532 | |
Valencia | 128 | 4989631 | |
Extremadura | 10 | 1096421 | |
Murcia | 67 | 1453545 |
View google_covid_mobility_scraper.R
# Install and load required packages | |
install.packages("needs") | |
library(needs) | |
needs(tidyverse, magrittr, animation, pdftools, png, scales) | |
# Function that extracts data from Google Mobility PDFs | |
process_google_mobility <- function(country_code, start_date, end_date){ | |
# Convert first page of PDF into high-res PNG | |
pdf_convert(paste0("https://www.gstatic.com/covid19/mobility/",end_date,"_",country_code,"_Mobility_Report_en.pdf"), format = "png", pages = 1, dpi = 300, filenames = "IMG1.png") |
View ireland_consituency_results_map.R
install.packages("needs") | |
library(needs) | |
needs(tidyverse, magrittr, rvest, sf, raster, rgdal) | |
ireland_constits <- c("https://en.wikipedia.org/wiki/Carlow%E2%80%93Kilkenny_(D%C3%A1il_constituency)") %>% | |
read_html() %>% | |
html_nodes('div[aria-labelledby="Current_Dáil_constituencies"] tr:nth-child(2) ul li a') %>% | |
html_attr("href") %>% | |
tail(-1) %>% | |
c("/wiki/Carlow%E2%80%93Kilkenny_(D%C3%A1il_constituency)", .) |
View covid_cases_script.R
install.packages("needs") | |
library(needs) | |
needs(tidyverse, magrittr, rvest, zoo, scales) | |
WHO_sars_links <- read_html("https://www.who.int/csr/sars/country/en/") %>% | |
html_nodes("ul.auto_archive") %>% | |
magrittr::extract(1) %>% | |
html_nodes("li a") %>% | |
map_dfr(~{ | |
link <- .x %>% html_attr("href") %>% paste0("https://www.who.int",.) |
View city_populations_projections.csv
year | value | name | group | lastValue | subGroup | lat | lon | city_id | |
---|---|---|---|---|---|---|---|---|---|
1575 | 200 | Agra | India | 200 | India | 27.18333 | 78.01667 | Agra - India | |
1576 | 212 | Agra | India | 200 | India | 27.18333 | 78.01667 | Agra - India | |
1577 | 224 | Agra | India | 212 | India | 27.18333 | 78.01667 | Agra - India | |
1578 | 236 | Agra | India | 224 | India | 27.18333 | 78.01667 | Agra - India | |
1579 | 248 | Agra | India | 236 | India | 27.18333 | 78.01667 | Agra - India | |
1580 | 260 | Agra | India | 248 | India | 27.18333 | 78.01667 | Agra - India | |
1581 | 272 | Agra | India | 260 | India | 27.18333 | 78.01667 | Agra - India | |
1582 | 284 | Agra | India | 272 | India | 27.18333 | 78.01667 | Agra - India | |
1583 | 296 | Agra | India | 284 | India | 27.18333 | 78.01667 | Agra - India |
View extract_values_from_bar_charts.R
needs(tidyverse, magrittr, png) | |
# Create a folder for storing the charts | |
dir.create("BFB_images") | |
# Loop though constituency codes in England and Wales, downloading the chart for each on from BfB | |
for(pcon in c(B4B_MRP$westminster_constituency[B4B_MRP$region != "Scotland"])){ | |
tryCatch(download.file(paste0("https://www.getvoting.org/charts/",pcon,"_1.png"), destfile = paste0("BFB_images/", pcon, ".png")), error = function(e){message("No chart")}) | |
} |
View USoc_driving_licence.R
needs(sjlabelled, tidyverse, haven, magrittr) | |
# Load wave 8 | |
USoc_indresp_8 <- read_dta("~/Downloads/UKDA-6614-stata/stata11_se/ukhls_w8/h_indresp.dta", encoding = "latin1") | |
# Load all other waves | |
USoc_indresp_1 <- read_dta("~/Downloads/UKDA-6614-stata/stata11_se/ukhls_w1/a_indresp.dta", encoding = "latin1") | |
USoc_indresp_2 <- read_dta("~/Downloads/UKDA-6614-stata/stata11_se/ukhls_w2/b_indresp.dta", encoding = "latin1") | |
USoc_indresp_3 <- read_dta("~/Downloads/UKDA-6614-stata/stata11_se/ukhls_w3/c_indresp.dta", encoding = "latin1") | |
USoc_indresp_4 <- read_dta("~/Downloads/UKDA-6614-stata/stata11_se/ukhls_w4/d_indresp.dta", encoding = "latin1") |
View custom_unit_histograms_in_R.R
install.packages("needs") | |
library(needs) | |
needs(tidyverse, magrittr) | |
# I’m using an example dataset of net national income per capita, from the World Bank (https://data.worldbank.org/indicator/NY.ADJ.NNTY.PC.CD?most_recent_value_desc=true) | |
head(dataset) | |
# Here’s a basic histogram using the ggplot defaults to show the distribution of NNI per capita across the world: | |
ggplot(dataset, aes(value)) + | |
geom_histogram() |
View sample.csv
We can make this file beautiful and searchable if this error is corrected: Any value after quoted field isn't allowed in line 2.
id,Data source citation,Class,Order,Family,Genus,Species,Sub species,Authority,Common Name,Location of population,Country list,Region,Decimal Latitude,Decimal Longitude,Are coordinates for specific location?,system,biome,realm,Native,Alien,Invasive,Units,Sampling method,Data transformed,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014, | |
7,"WWF-SA (2000). "Cape griffon."",Aves,Accipitriformes,Accipitridae,Gyps,coprotheres,,"(Forster, 1798)",Cape griffon / Cape vulture,"Botswana","Botswana",Africa,-22.0,24.0,false,Terrestrial,Tropical and subtropical grasslands, savannas and shrublands,Afrotropical,Yes,No,No,Individuals,Unknown,No,,,,,,685,,,,,815,,,,,,,,,,655,,,,,,,,,,704,,,,,,,,,,,,,,, | |
8,"WWF-SA (2000). "Cape griffon."",Aves,Accipitriformes,Accipitridae,Gyps,coprotheres,,"(Forster, 1798)",Cape griffon / Cape vulture,"Lesotho","Lesotho",A |
NewerOlder