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(osmdata) # package for working with streets | |
library(showtext) # for custom fonts | |
library(ggmap) | |
library(rvest) | |
big_streets <- getbb("Canarias") %>% | |
opq()%>% | |
add_osm_feature(key = "highway", |
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(data.table) | |
library(dtplyr) | |
library(dplyr, warn.conflicts = FALSE) | |
library(microbenchmark) | |
library(ggplot2) | |
set.seed(123) | |
df <- data.frame( | |
letters = sample(c('A', 'B', 'C'), size = 3e6, replace = TRUE, prob = c(.5, .4, .1)), | |
number = sample(c(1:5), size = 3e6, replace = 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
import pandas_datareader as pdr | |
import matplotlib.pyplot as plt | |
from statsmodels.tsa.stattools import adfuller | |
from statsmodels.graphics.tsaplots import plot_acf | |
import seaborn as sns | |
import warnings | |
from statsmodels.tsa.arima_model import ARIMA | |
from sklearn.metrics import mean_squared_error | |
warnings.filterwarnings("ignore") |
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(lubridate) | |
tst <- readr::read_csv('https://raw.githubusercontent.com/washingtonpost/data-police-shootings/master/fatal-police-shootings-data.csv') | |
tst1 <- | |
tst %>% | |
filter(race != 'N', year(date) < 2020) %>% | |
mutate(Raza = ifelse(race == 'W', 'Blancos', 'Otros')) %>% | |
filter(armed == 'unarmed') %>% |
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(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(R0) | |
library(EpiEstim) | |
# read data | |
url_confirmed <- "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv" | |
corona <- data.table::fread(url_confirmed) %>% as_tibble() | |
corona[c("Province/State", "Lat", "Long")] <- NULL |
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
# Ugly code for tacking Covid-19 in Spain | |
# load libraries | |
library(readr) | |
library(ggplot2) | |
library(tidyr) | |
library(dplyr) | |
library(grid) | |
library(gridExtra) | |
library(tabulizer) |
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
``` r | |
wilcox_test <- function(x, y) { | |
# build the dataframe | |
df <- data.frame(x, y) | |
# calculate the absolute difference, sign and rank it | |
df$dif <- abs(x - y) | |
df <- subset(df, dif != 0) | |
df$sign <- sign(df$x - df$y) |
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(sf) # classes and functions for vector data | |
library(raster) # classes and functions for raster data | |
library(spData) # load geographic data | |
library(spDataLarge) # load larger geographic data | |
renta <- readr::read_csv2("./data/data_renta.csv", col_types = cols( | |
cp = col_character(), | |
numero_declaraciones = col_number(), | |
renta_media = col_number(), |
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
# load packages | |
library(readr) | |
library(tidyr) | |
library(ggplot2) | |
library(gifski) | |
library(gganimate) | |
library(dplyr) | |
# load data | |
tst <- readr::read_csv("https://elpais.com/especiales/2019/elecciones-generales/encuestas-electorales/ficheros/tabla.csv?1554807308", |
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(httr) | |
library(dplyr) | |
library(magrittr) | |
library(purrr) | |
get_holidays <- function(country_code, year) { | |
# Build URL | |
url <- parse_url("http://date.nager.at") | |
url$path <- paste0("api/v1/get/", country_code, "/", year) |
NewerOlder