Skip to content

Instantly share code, notes, and snippets.

Jorge López Pérez jlopezper

Block or report user

Report or block jlopezper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View wilcoxon.R
``` 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)
View renta_lpgc.R
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(),
View gganimate_reprex
# 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",
View get_holidays.R
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)
View count_correct_csv.R
# install.packages("devtools")
devtools::install_github("ropenspain/opendataes")
library(opendataes)
determine_number <- function(x) {
check_read <- function(data) !all(names(data) %in% c('name', 'format', "URL"))
has_url_col <- vapply(x[[2]], check_read, logical(1))
number_of_reads <- sum(has_url_col)
View simulation_e_number.R
runs <- 100000
threshold <- 1000
Res = vector(mode = "numeric")
for (k in 1:runs){
i <- 1
v <- vector(mode = "numeric")
while (sum(v) < threshold) {
v[i] <- runif(1,0,1000)
@jlopezper
jlopezper / library_visits.R
Last active Jul 25, 2018
Using CKANR API with OpenDataBCN
View library_visits.R
# Load libraries
library(ckanr)
library(XML)
library(ggmap)
library(dplyr)
# API Setup
ckanr_setup(url = "http://opendata-ajuntament.barcelona.cat/data")
You can’t perform that action at this time.