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
# 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")) %>%
@pachadotdev
pachadotdev / titanic.csv
Created April 26, 2019 14:18
datos pasajeros del titanic
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
@pachadotdev
pachadotdev / rstudio-server-setup.sh
Last active March 18, 2019 22:47
RStudio Server setup on Digital Ocean droplet
#!/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
@pachadotdev
pachadotdev / esperanza_de_vida.R
Last active February 20, 2019 12:55
trying to reproduce esperanza_de_vida error in R4DS es
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
@pachadotdev
pachadotdev / index.html
Created February 12, 2019 18:56
d3plus v2 treemap with v1 styles
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="https://d3plus.org/js/d3plus-hierarchy.v0.8.full.min.js"></script>
<style>
@pachadotdev
pachadotdev / geomap_example.html
Last active February 6, 2019 21:41
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>
@pachadotdev
pachadotdev / datasaurus.csv
Created January 22, 2019 21:15
Alberto Cairo's Datasaurus Dozen for summary statistics
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>PACHA</string>
<key>comment</key>
<string>Created by Pacha based on Pop OS terminal palette</string>
<key>name</key>
<string>Pop</string>
@pachadotdev
pachadotdev / bev.csv
Created September 27, 2018 14:21
Beverages sales
M.hi.p M.lo.p MET.hi.p MET.lo.p MET.sp.p SEC.hi.p SEC.lo.p M.hi M.lo MET.hi MET.lo MET.sp SEC.hi SEC.lo
59.25 29.19 63.67 26.03 50.09 58.56 29.19 458 1455 2037 3437 468 156 544
56.26 26.31 60.34 25.54 48.82 54.64 26.31 477 1756 1700 3436 464 151 624
56.26 26.25 60.79 25.69 48.56 57.9 26.25 539 2296 1747 3304 490 178 611
49.33 26.15 55.09 26.46 47.74 49.7 26.15 687 3240 2371 3864 657 217 646
61.34 25.88 65.09 25.72 50.75 63.72 25.88 389 2252 1741 3406 439 141 624
61.4 27.35 67.91 26.17 52.63 68.38 27.35 399 1901 2072 3418 453 149 610
65.83 26.67 69.43 25.38 51.36 67.84 26.67 392 1939 2353 3553 423 134 623
60.34 26.17 65.56 25.64 51.44 63.93 26.17 417 1999 2909 3376 408 148 599
46.77 27.2 53.56 25.94 48.27 46.71 27.2 568 1798 3204 3233 501 195 551
@pachadotdev
pachadotdev / getHexValue.gs
Created May 18, 2018 19:41
extract cells background color
function getHexValue(range) {
return SpreadsheetApp.getActive().getRange(range).getBackground();
}