Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Pachamaltese pachamaltese

🎯
Focusing
Block or report user

Report or block pachamaltese

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 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
@pachamaltese
pachamaltese / index.html
Created Feb 12, 2019
d3plus v2 treemap with v1 styles
View index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="https://d3plus.org/js/d3plus-hierarchy.v0.8.full.min.js"></script>
<style>
View geomap_example.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="https://d3plus.org/js/d3plus-geomap.v0.6.full.min.js"></script>
<style>
@pachamaltese
pachamaltese / datasaurus.csv
Created Jan 22, 2019
Alberto Cairo's Datasaurus Dozen for summary statistics
View datasaurus.csv
dataset x y
dino 22.3077 61.7949
dino 22.3077 57.1795
dino 23.0769 66.4103
dino 23.3333 52.9487
dino 25.8974 51.0256
dino 26.1538 71.4103
dino 28.9744 74.4872
dino 29.4872 51.0256
dino 29.7436 36.0256
You can’t perform that action at this time.