Skip to content

Instantly share code, notes, and snippets.

View jlopezper's full-sized avatar

Jorge López Pérez jlopezper

View GitHub Profile
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",
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)
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")
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') %>%
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
# Ugly code for tacking Covid-19 in Spain
# load libraries
library(readr)
library(ggplot2)
library(tidyr)
library(dplyr)
library(grid)
library(gridExtra)
library(tabulizer)
``` 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)
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(),
# 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",
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)