Skip to content

Instantly share code, notes, and snippets.

View omarbenites's full-sized avatar
:octocat:
open data tools for the agronomy world 🍠 🌽 🍅

Omar Benites Alfaro omarbenites

:octocat:
open data tools for the agronomy world 🍠 🌽 🍅
  • METRIKA
  • Lima-Peru
View GitHub Profile
@omarbenites
omarbenites / ggparliament_example.R
Created July 16, 2018 04:18 — forked from zmeers/ggparliament_example.R
ggparliament example
# ggparliament example
# Zoe Meers
# 12 July 2018
#
library(tidyverse)
library(ggparliament) # download from github using devtools.
# predictions from NY Times -- see https://www.nytimes.com/interactive/2018/03/26/us/elections/house-races-midterms.html
# Regarding order -- from the POV of the speaker, Republicans sit to the left of the chamber and Democrats to the right.
@omarbenites
omarbenites / 1. intro.md
Created March 6, 2017 16:47 — forked from xhdong-umd/1. intro.md
R function that decompress zip, gz, bzip2, xz into temp file, run function then remove temp file

The need of this came from the fact that read.csv can read zip files directly but data.table::fread cannot take connections as input since it requires random file seek. There is simple usage of data.table::fread(paste0("zcat < ", PATH_TO_FILE)) but that depend on command line tool gzip, which is not always available in windows. See here for more details.

The code is based on R.utils::decompressFile with lots of modifications:

  1. no more removing input file. I lost several data files and puzzled too much time because of this even if I read the document and knew this behavior in the beginning.
  2. According to ?connections, `gzfile`` can handle gz, bzip2, xz. No need to specify and use different functions for uncompress.
  3. The only exception is gzfile cannot handle zip. We can use unzip to decompress file directly without need of connections. unzip does not support Unicode filenames as introduced in zip 3.0. See more in ?unzip for its li
@omarbenites
omarbenites / global.R
Last active August 29, 2015 14:18 — forked from pssguy/global.R
# load required libraries
library(shiny)
library(plyr)
library(ggplot2)
library(googleVis)
library(reshape2)
####creation of example data on local directory for uploading####
@omarbenites
omarbenites / k-fold CV.r
Last active August 29, 2015 14:16 — forked from bhoung/k-fold CV.r
# original example from Digg Data website (Takashi J. OZAKI, Ph. D.)
# http://diggdata.in/post/58333540883/k-fold-cross-validation-in-r
library(plyr)
library(randomForest)
data <- iris
# in this cross validation example, we use the iris data set to