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
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",.) |
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
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 |
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
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)", .) |
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
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 |
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
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")}) | |
} |
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
group | total | share | clubName | barTops | barBases | ||
---|---|---|---|---|---|---|---|
1 | England | 14921 | 0.656474107967794 | afc-bournemouth | 0.656474107967794 | 0 | |
2 | Rest of UK | 1896 | 0.0834176602578204 | afc-bournemouth | 0.739891768225615 | 0.656474107967794 | |
3 | Ireland | 1591 | 0.0699986801003124 | afc-bournemouth | 0.809890448325927 | 0.739891768225615 | |
4 | non-EU | 1035 | 0.045536539223019 | afc-bournemouth | 0.855426987548946 | 0.809890448325927 | |
5 | Other EU | 3286 | 0.144573012451054 | afc-bournemouth | 1 | 0.855426987548946 | |
6 | England | 2489 | 0.10993816254417 | arsenal-fc | 0.10993816254417 | 0 | |
7 | Rest of UK | 1678 | 0.0741166077738516 | arsenal-fc | 0.184054770318021 | 0.10993816254417 | |
8 | non-EU | 2611 | 0.115326855123675 | arsenal-fc | 0.299381625441696 | 0.184054770318021 | |
9 | Other EU | 15862 | 0.700618374558304 | arsenal-fc | 1 | 0.299381625441696 |
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
<!doctype html> | |
<html class="no-js" lang=""> | |
<head> | |
<meta charset="utf-8"> | |
<title>Canvas City</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> | |
<canvas></canvas> |
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
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") |
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
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() |
We can make this file beautiful and searchable if this error is corrected: Any value after quoted field isn't allowed in line 2.
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
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 |