Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Pachamaltese pachamaltese

🎯
Focusing
View GitHub Profile
View ufdolar.R
library(mindicador)
library(readr)
valoruf <- mindicador_importar_datos(
series = "uf",
anios = 2020,
tipo = "data.frame",
max_intentos = 5,
usar_cache = FALSE,
archivo = NULL
View guaguas.R
source("00-leer-datos.R")
library(dplyr)
# ejemplo 1: filtrar, agrupar y contar
guaguas %>%
filter(anio >= 1990 & nombre == "Bryan") %>%
group_by(anio) %>%
count()
View hcmap-europe.R
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))
View ejemplo1-codigo-tradestatistics.R
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) %>%
@pachamaltese
pachamaltese / treemap.R
Created Aug 26, 2019
echarts4r advanced treemap hacks
View treemap.R
library(dplyr)
library(stringr)
library(echarts4r)
n <- 5
set.seed(123)
colors <- c("#d35400", "#2980b9", "#2ecc71", "#f1c40f", "#2c3e50", "#7f8c8d")
@pachamaltese
pachamaltese / d3po.js
Last active Aug 9, 2019
treemap error d3 4.13
View d3po.js
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 = []
View reproducible_example.R
# packages ----
if (!require("pacman")) install.packages("pacman")
p_load(data.table, tidyr, tidytext, dplyr, ggplot2, viridis, ggstance, igraph, ggraph)
p_load_gh("dgrtwo/widyr")
# tidy ----
rick_and_morty_subs <- as_tibble(fread("rick_and_morty_subs_s01.csv")) %>%
mutate(text = iconv(text, to = "ASCII")) %>%
@pachamaltese
pachamaltese / titanic.csv
Created Apr 26, 2019
datos pasajeros del titanic
View titanic.csv
pclass survived name sex age sibsp parch ticket fare cabin embarked boat body home.dest
1 1 Allen, Miss. Elisabeth Walton female 29 0 0 24160 211.3375 B5 S 2 St Louis, MO
1 1 Allison, Master. Hudson Trevor male 0.9167 1 2 113781 151.5500 C22 C26 S 11 Montreal, PQ / Chesterville, ON
1 0 Allison, Miss. Helen Loraine female 2 1 2 113781 151.5500 C22 C26 S Montreal, PQ / Chesterville, ON
1 0 Allison, Mr. Hudson Joshua Creighton male 30 1 2 113781 151.5500 C22 C26 S 135 Montreal, PQ / Chesterville, ON
1 0 Allison, Mrs. Hudson J C (Bessie Waldo Daniels) female 25 1 2 113781 151.5500 C22 C26 S Montreal, PQ / Chesterville, ON
1 1 Anderson, Mr. Harry male 48 0 0 19952 26.5500 E12 S 3 New York, NY
1 1 Andrews, Miss. Kornelia Theodosia female 63 1 0 13502 77.9583 D7 S 10 Hudson, NY
1 0 Andrews, Mr. Thomas Jr male 39 0 0 112050 0.0000 A36 S Belfast, NI
1 1 Appleton, Mrs. Edward Dale (Charlotte Lamson) female 53 2 0 11769 51.4792 C101 S D Bayside, Queens, NY
@pachamaltese
pachamaltese / rstudio-server-setup.sh
Last active Mar 18, 2019
RStudio Server setup on Digital Ocean droplet
View rstudio-server-setup.sh
#!/bin/bash
# add CRAN to apt sources
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
printf '\n#CRAN mirror\ndeb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/\n' | sudo tee -a /etc/apt/sources.list
# update apt
apt-get -y update
# requisites for some R packages
@pachamaltese
pachamaltese / esperanza_de_vida.R
Last active Feb 20, 2019
trying to reproduce esperanza_de_vida error in R4DS es
View esperanza_de_vida.R
if(!require("pacman")) { install.packages("pacman") }
devtools::install_github("pachamaltese/datos")
pacman::p_load(purrr, dplyr, tidyr, datos)
# I need to know what's going on with this "selective" error
sessionInfo()
# inspect datos::paises (countries)
paises
You can’t perform that action at this time.