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
# The packages we'll be using | |
packages <- c("rvest","dplyr","tidyr","pipeR","ggplot2","stringr","data.table") | |
# From those packages, which ones are not yet installed? | |
newPackages <- packages[!(packages %in% as.character(installed.packages()[,"Package"]))] | |
# If any weren't already installed, install them now | |
if(length(newPackages)) install.packages(newPackages) | |
# Now make sure all necessary packages are loaded |
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
library(tidyverse) | |
gpi <- jsonlite::fromJSON("http://staging-maps.visionofhumanity.org/json_feeds/gpi.json?v=2.6.12&vv=2.6.12") | |
map(gpi, "csv") %>% | |
map_df(~read_csv(sprintf("http://staging-maps.visionofhumanity.org/csv/%s", .x))) %>% | |
docxtractr::mcga() -> gpi_df | |
glimpse(gpi_df) | |
## Observations: 1,618 |
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
library(rnaturalearth) | |
library(sf) | |
library(plotly) | |
library(crosstalk) | |
library(viridis) | |
ng <- ne_states(country = "Nigeria", returnclass = "sf") %>% | |
select(Name = name) | |
# Source: https://dhsprogram.com/pubs/pdf/FR293/FR293.pdf |
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
require(tidyverse) | |
require(ggthemes) | |
require(rjson) | |
require(jsonlite) | |
# 参考 | |
# https://www.data.jma.go.jp/gmd/risk/obsdl/index.php | |
# https://www.data.jma.go.jp/gmd/risk/obsdl/top/help3.html#hukajoho | |
# https://twitter.com/mehori/status/1020644999703089152 |
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
# Animated dplyr joins with gganimate | |
# * Garrick Aden-Buie | |
# * garrickadenbuie.com | |
# * MIT License: https://opensource.org/licenses/MIT | |
# Note: I used Fira Sans and Fira Mono fonts. | |
# Use search and replace to use a different font if Fira is not available. | |
library(tidyverse) | |
library(gganimate) |
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
library(tidycensus) | |
library(mapdeck) | |
library(tidyverse) | |
token <- "your mapbox token" | |
hv <- get_acs(geography = "tract", | |
variables = "B25077_001", | |
state = "CA", | |
geometry = TRUE) %>% |
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
library(tidyverse) | |
library(rvest) | |
library(ggimage) | |
library(lubridate) | |
#get first 25 leagues in Europe ---- | |
url <- "https://www.transfermarkt.de/wettbewerbe/europa" | |
doc <- read_html(url) | |
leagues <- doc %>% html_nodes(".hauptlink a") %>% html_attr("href") |
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, scales) | |
jose.porto <- read_csv("http://api.clubelo.com/porto") | |
jose.chelsea <- read_csv("http://api.clubelo.com/chelsea") | |
jose.inter <- read_csv("http://api.clubelo.com/inter") | |
jose.real <- read_csv("http://api.clubelo.com/realmadrid") | |
jose.mufc <- read_csv("http://api.clubelo.com/manunited") | |
jose.all <- bind_rows( | |
jose.porto %>% filter(From >= as.Date("2002-01-22") & To <= as.Date("2004-06-30")), |
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
library(tidyverse) | |
lights_dat <- read_csv("https://ckan.dataplatform.nl/dataset/83402c68-1c05-4aa5-ab28-2e99d2bc2261/resource/dc10e0ac-351a-49b6-b3db-d0152c29dc02/download/paal-20180906.csv") | |
pp <- | |
lights_dat %>% | |
filter(latitude > 50) %>% | |
ggplot(aes(x = longitude, y = latitude)) + | |
geom_point(alpha = 0.03, fill = "#FAFAAB", stroke = 0, pch = 21, size = 1.6) + | |
geom_point(alpha = 0.8, fill = "#FAFAAB", stroke = 0, pch = 21, size = 0.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
# Prepare world data | |
# First up, we need to load the built-up area data that we’re going to be plotting. We download this from the European Commission’s Global Human Settlement Data portal [https://ghsl.jrc.ec.europa.eu/datasets.php] — specifically using the links from this page [http://cidportal.jrc.ec.europa.eu/ftp/jrc-opendata/GHSL/GHS_BUILT_LDSMT_GLOBE_R2015B/]. We want the 250m-resolution rasters for 1975 and 2015 (GHS_BUILT_LDS1975_GLOBE_R2016A_54009_250 and GHS_BUILT_LDS2014_GLOBE_R2016A_54009_250). | |
# Once you’ve downloaded these (they’re BIG, so might take a little while...), we can save ourselves a lot of hassle later on by re-projecting them into the same co-ordinate space as the other data we’re going to be using. Specifically we want to change their units from metres to lat/lon. We do this by: | |
# 1) Unzipping the archive, and then | |
# 2) Running the following script on the command-line: | |
# gdalwarp -t_srs EPSG:4326 -tr 0.01 0.01 path/to/your/built-up-area.tif path/to/your/built-up-area_reprojected. |
OlderNewer