Skip to content

Instantly share code, notes, and snippets.

@javieroot
javieroot / Manipulating_data
Created November 25, 2017 20:33 — forked from aaronsaunders/Manipulating_data
Manipulating data
with()
within()
round(x, n) # rounds x to n decimal places
ceiling(x) # vector x of smallest integers > x
floor(x) # vector x of largest interger < x
as.integer(x) # truncates real x to integers (compare to round(x, 0)
as.integer(x < cutpoint) # vector x of 0 if less than cutpoint, 1 if greater than cutpoint)
@javieroot
javieroot / Install_R.R
Created November 25, 2017 19:54 — forked from dmarcelinobr/Install_R.R
R script and instructions to install commonly used R packages and instructions for using OpenBLAS on OS X via Homebrew Raw
##############################################################################
# title : InstallPackages.R;
# purpose : install R packages commonly used by Adam H.Sparks when upgrading or installing R;
# producer : prepared by A. H. Sparks;
# last update : in Los Baños, Laguna, PHL, May 2015;
# inputs : none;
# outputs : none;
# remarks 1 : in order to download any packages, you need to be on-line, of course;
# remarks 2 : for country outlines and the like see http://www.gadm.org/ to download Rdata packages;
##############################################################################
@javieroot
javieroot / gist:407f1b3d1d80c574b597a84a99b71bda
Created November 25, 2017 19:16 — forked from OmarGonD/gist:b70b712327d7e479f2c7
Web Scrapping - Get 2 nodes at the same time
library(RSelenium)
library(rvest)
#start RSelenium
checkForServer()
startServer()
remDr <- remoteDriver()
remDr$open()
#navigate to your page
remDr$navigate("http://www.linio.com.pe/celulares-telefonia-y-gps/")
@javieroot
javieroot / gg_themes.R
Created November 15, 2017 18:22 — forked from aravindhebbali/gg_themes.R
ggplot2: Themes
# install
install.packages('ggplot2')
install.packages('readr')
# load
library(ggplot2)
library(readr)
# Scatter Plot
p <- ggplot(mtcars) +
@javieroot
javieroot / clean-headers.R
Created September 21, 2017 21:20 — forked from erinshellman/clean-headers.R
A collection of little helper functions for quick data cleaning in R
clean_headers = function(headers) {
# Make lowercase
headers = tolower(headers)
# Replace symbols
headers = gsub(' ', '', headers, fixed = TRUE)
headers = gsub('.', '_', headers, fixed = TRUE)
headers = gsub('[^[:alnum:]_]', '', headers) # remove all symbols except '_'
@javieroot
javieroot / ggplot2_IMPROVE.R
Last active November 11, 2017 20:32 — forked from allenaven/ggplot2_IMPROVE.R
Improve the standard ggplot2 plot! Increase text size, get rid of the grey background!!!
## library(devtools)
## source_gist(7489113)
## use like this: ggplot(mtcars, aes(x=hp, y=mpg)) + geom_point(aes(col=factor(cyl)), size=3) + t1
t1 <- theme(
plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank(),
@javieroot
javieroot / lookfor.R
Created September 21, 2017 17:07 — forked from briatte/lookfor.R
lookfor -- an equivalent to the -lookfor- Stata command that supports foreign and memisc data objects (part of the questionr package)
lookfor <- function(data,
keywords = "weight|sample",
labels = TRUE,
ignore.case = TRUE) {
# search scope
n <- names(data)
if(!length(n)) stop("there are no names to search in that object")
# search function
look <- function(x) { grep(paste(keywords, collapse="|"), x, ignore.case = ignore.case) }
# names search
@javieroot
javieroot / SeriesARMA.R
Created September 21, 2017 16:02 — forked from marco-lopes/SeriesARMA.R
Comandos em R para a modelagem de séries temporais ARMA
# Ativando o módulo de séries temporais
library(tseries)
serie<-read.ts("telesp.txt", header = FALSE, sep = "", skip = 0)
# Gráfico da serie
ts.plot(serie)
@javieroot
javieroot / latlng.sh
Created May 17, 2017 17:45 — forked from manchoz/latlng.sh
Address geocoding in Bash with Google Maps API
#!/bin/bash
# Quick and dirty geocoding with Google Maps API
MAPSAPIURL="http://maps.googleapis.com/maps/api/geocode/json"
[ -f latlng.txt ] && rm latlng.txt
[ -f results.json ] && rm results.json
while read line; do
# Get address from column 3 and 4 of a CSV file provided as argument and prepare the string address. YMMV.
@javieroot
javieroot / tricks-miscelanea
Created October 14, 2016 16:50 — forked from andru255/tricks-miscelanea
trucos encontrados de vim en la web y en el camino - miscelanea
shift + 3(del teclado no numérico) = busca la palabra donde está enfocado el cursor
:edit! = para refrescar un archivo actual para verificar si tiene cambios de otro.
¿ zz = para guardar y salir directamente ?
//// pestañas
:tabe = crea una nueva pestaña vacía
:tab sp {file} = crea un clon del archivo en una nueva pestaña
:tabe = crea un clon del archivo en una nueva pestaña