This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<meta charset="utf-8"> | |
<script src="http://d3plus.org/js/d3.js"></script> | |
<script src="http://d3plus.org/js/d3plus.js"></script> | |
<div id="viz"></div> | |
<script> | |
var nodes = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"region": "Tarapacá", | |
"comuna": "Iquique", | |
"poblacion": 145881, | |
"encuentros": 229, | |
"encuentros_10000hab": 15.698, | |
"pcent_elas": 1.525, | |
"pcent_votos": 0.821, | |
"idh": 0.766, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"comuna": "Santiago", | |
"poblacion": 139180, | |
"encuentros_10000hab": 69.335, | |
"indice_participacion": 68.6176, | |
"color": "#717290" | |
}, | |
{ | |
"comuna": "Cerrillos", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############ | |
# Libraries | |
############ | |
packages_cran <- c("devtools", "stringi", "data.table") | |
download_cran <- function(pkg){ | |
new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])] | |
if (length(new.pkg) > 0) { | |
install.packages(new.pkg, dependencies = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It is best to use r.squaredGLMM() function from the MuMIn package | |
# The original function was made by Jon Lefcheck | |
############## | |
# Dependencies | |
############## | |
libraries = c("lme4","nlme") | |
download_and_or_load <- function(pkg){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See http://pacha.hk/2017-07-15_gnu_nongnu_homebrew.html | |
# XCode CLT | |
xcode-select --install | |
# Update Homebrew and add formulae | |
brew update | |
# Check for broken dependencies and/or outdated packages | |
brew doctor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!require("pacman")) install.packages("pacman") | |
p_load(rtweet,jsonlite,dplyr,readr) | |
key = "xxx" #retrieve this from dev.twitter.com under keys and tokens | |
secret = "yyy" #retrieve this from dev.twitter.com under keys and tokens | |
twitter_token = create_token("extract_data_with_r", key, secret, cache = TRUE) | |
saveRDS(twitter_token, file = "twitter_token.rds") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Librerias e importacion de datos | |
library(googlesheets) | |
library(dplyr) | |
library(tidyr) | |
library(lubridate) | |
library(ggplot2) | |
library(ggthemes) | |
library(viridis) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adapted from https://gist.githubusercontent.com/andrewheiss/926b9d60a26e29f6bf32/raw/a09ecbca4613381a782b93e8aeaa4132016205b7/neighbors.R | |
# Map libraries | |
# You must install geos (http://trac.osgeo.org/geos/) and | |
# gdal (http://www.gdal.org/) first. | |
# OS X: `brew install geos gdal` | |
# Ubuntu: sudo apt-get install libgeos-dev libgdal-dev libproj-dev | |
# Then install these packages from source | |
# install.packages(c("rgeos", "rgdal"), type="source") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add CRAN to apt sources | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 | |
printf '\n#CRAN mirror\ndeb https://cran.dcc.uchile.cl/bin/linux/ubuntu xenial/\n' | sudo tee -a /etc/apt/sources.list | |
# install R | |
sudo apt-get update | |
sudo apt-get install libxml2-dev libssl-dev libcurl4-gnutls-dev gfortran libopenblas-dev | |
sudo apt-get install r-base r-base-dev | |
# install common packages |