Skip to content

Instantly share code, notes, and snippets.

View pachadotdev's full-sized avatar
🎯
Focusing

Mauricio "Pachá" Vargas Sepúlveda pachadotdev

🎯
Focusing
View GitHub Profile
@pachadotdev
pachadotdev / yotov_ch1_application1_1000rows.csv
Created November 17, 2020 00:33
random sample of Yotov's AGTPA application 1 from chapter 1
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 23 columns, instead of 22. in line 3.
exporter,importer,pair_id,year,trade,dist,cntg,lang,clny,log_trade,log_dist,y,log_y,e,log_e,total_e,remoteness_exp,log_remoteness_exp,total_y,remoteness_imp,log_remoteness_imp,exp_year,imp_year
ROM,PRT,2197,2006,29.6067590815127,2926.63232206783,0,0,0,3.388002682611129,7.981607662835646,66298.04836186398,11.101915739268053,106818.18165712024,11.578883431254216,26248052.9686006,661604212.536981,20.31017806884965,26248052.9686006,995955630.3332468,20.7192132666984,ROM2006,PRT2006
NGA,NPL,2014,2006,0,8533.95813886414,0,0,0,-Inf,9.051808558517276,99373.4161630537,11.506639913847772,4881.484603951256,8.493204674702186,26248052.9686006,493911281.07403946,20.017866466055917,26248052.9686006,1525909073.422258,21.145856183120095,NGA2006,NPL2006
FIN,GRC,691,1990,148.285043270111,2544.74481018791,0,0,0,4.999136389506888,7.841785652911137,74506.29053439197,11.21863883750632,39912.5679797954,10.594446540242267,12246859.677430546,944377422.2668016,20.66603645592967,12246859.677430546,967819738.2760613,20.690556407110414,FI
@pachadotdev
pachadotdev / pokemon.json
Created October 16, 2020 20:59
pokemon treemap
[{"id":1,"name":"Bulbasaur","height":0.7,"weight":6.9,"base_experience":64,"type_1":"grass","type_2":"poison","attack":49,"defense":49,"hp":45,"special_attack":65,"special_defense":65,"speed":45,"color_1":"#78C850","color_2":"#A040A0"},{"id":2,"name":"Ivysaur","height":1,"weight":13,"base_experience":142,"type_1":"grass","type_2":"poison","attack":62,"defense":63,"hp":60,"special_attack":80,"special_defense":80,"speed":60,"color_1":"#78C850","color_2":"#A040A0"},{"id":3,"name":"Venusaur","height":2,"weight":100,"base_experience":236,"type_1":"grass","type_2":"poison","attack":82,"defense":83,"hp":80,"special_attack":100,"special_defense":100,"speed":80,"color_1":"#78C850","color_2":"#A040A0"},{"id":4,"name":"Charmander","height":0.6,"weight":8.5,"base_experience":62,"type_1":"fire","attack":52,"defense":43,"hp":39,"special_attack":60,"special_defense":50,"speed":65,"color_1":"#F08030"},{"id":5,"name":"Charmeleon","height":1.1,"weight":19,"base_experience":142,"type_1":"fire","attack":64,"defense":58,"hp":58,"
library(igraph)
library(ggraph)
mtcars_cor <- (cor(mtcars))^2
mtcars_cor <- (-1) * mtcars_cor
g <- graph_from_adjacency_matrix(mtcars_cor, weighted = TRUE,
mode = "undirected", diag = FALSE)
g_mst <- mst(g, algorithm = "prim")
#!/bin/bash
set -o nounset
case "${1:-}" in
--)
pdf="$2"
html="${pdf%.pdf}".html
dest="${html}".gz
[ -e "$dest" ] && exit
@pachadotdev
pachadotdev / ufdolar.R
Created July 30, 2020 00:28
mindicador
library(mindicador)
library(readr)
valoruf <- mindicador_importar_datos(
series = "uf",
anios = 2020,
tipo = "data.frame",
max_intentos = 5,
usar_cache = FALSE,
archivo = NULL
@pachadotdev
pachadotdev / guaguas.R
Last active July 30, 2020 00:01
guaguas
source("00-leer-datos.R")
library(dplyr)
# ejemplo 1: filtrar, agrupar y contar
guaguas %>%
filter(anio >= 1990 & nombre == "Bryan") %>%
group_by(anio) %>%
count()
library(dplyr)
library(highcharter)
mapData <- tibble(
country = c("PT", "IE", "GB", "IS",
"NO", "SE", "DK", "DE", "NL", "BE", "LU", "ES", "FR", "PL", "CZ", "AT",
"CH", "LI", "SK", "HU", "SI", "IT", "SM", "HR", "BA", "YF", "ME", "AL", "MK",
"FI", "EE", "LV", "LT", "BY", "UA", "MD", "RO", "BG", "GR", "TR", "CY",
"RU"),
value = c(rep(1,4), rep(2,25), rep(3,12), 4))
library(dplyr)
library(tradestatistics)
fji_usa <- ots_create_tidy_data(
years = 2017, reporters = "fji", partners = "usa",
include_shortnames = T
)
fji_usa_2 <- fji_usa %>%
select(product_shortname_english, export_value_usd) %>%
arrange(-export_value_usd) %>%
@pachadotdev
pachadotdev / treemap.R
Created August 26, 2019 17:26
echarts4r advanced treemap hacks
library(dplyr)
library(stringr)
library(echarts4r)
n <- 5
set.seed(123)
colors <- c("#d35400", "#2980b9", "#2ecc71", "#f1c40f", "#2c3e50", "#7f8c8d")
@pachadotdev
pachadotdev / d3po.js
Last active August 9, 2019 01:37
treemap error d3 4.13
This file has been truncated, but you can view the full file.
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict'
exports.byteLength = byteLength
exports.toByteArray = toByteArray
exports.fromByteArray = fromByteArray
var lookup = []
var revLookup = []
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array