Skip to content

Instantly share code, notes, and snippets.

@rpietro
rpietro / oecd_ed_expend.csv
Created September 1, 2013 14:30
Cleaned OECD data about education expenditure. Source: http://www.oecd.org/edu/eag2013%20(eng)--FINAL%2020%20June%202013.pdf
countries pre_primary_exp intermediate_exp tertiary_exp pre_primary_gdp intermediate_gdp tertiary_gdp
Australia 0.2 11.5 3.4 0.1 3.9 1.1
Austria 1.2 7 3.1 0.6 3.6 1.6
Belgium 1.2 8.2 2.8 0.6 4.3 1.5
Canada 8.5 4.7 3.4 1.9
Chile 2.3 11.6 3.9 0.5 2.7 0.9
Czech Republic 1.1 6.1 2.2 0.5 2.7 1
Denmark 1.8 8.9 4.2 1 5.1 2.4
Estonia 1.1 9.8 3 0.4 4 1.2
Finland 0.7 7.6 3.9 0.4 4.3 2.2
@rpietro
rpietro / oecd_ed_expend.r
Created September 1, 2013 14:39
Analysis of OECD data on education expenditure
#install.packages(c("ggplot2", "gridExtra", "RCurl"))
lapply(c("ggplot2", "gridExtra", "RCurl"), require, character.only = T)
require(ggplot2)
require(gridExtra)
require(RCurl)
# to get the direct link to the csv file from the gist, just click on the <> symbol on the top right corner of the gist
gist <- getURL("https://gist.github.com/rpietro/6404791/raw/9afb4fc45c10592ccd6dcb5cef0fa4c7667b35a7/oecd_ed_expend.csv")
ed <- read.csv(gist)
@rpietro
rpietro / sound_graphic.r
Created September 2, 2013 13:43
graphic representing the recording of a song emitted by a male of the neotropical sparrow Zonotrichia capensis. source http://rug.mnhn.fr/seewave/ex37.html
install.packages(c("seewave", "fftw", "tuneR", "rgl", "rpanel"), repos="http://cran.at.r-project.org/")
require(ggplot2)
require(seewave)
data(tico)
tico
oscillo(tico,f=22050)
v <- ggspectro(tico, ovlp=35)
v + geom_tile(aes(fill = amplitude)) + stat_contour()
@rpietro
rpietro / slidify.r
Created September 3, 2013 17:06
slidify sequence
setwd("~/Desktop")
require(devtools)
# pkgs = c('slidify', 'slidifyLibraries')
# install_github(pkgs, 'ramnathv', ref = 'dev')
library(slidify)
library("slidifyLibraries")
author("")
slidify("index.Rmd")
publish(user = "USER", repo = "REPO")
@rpietro
rpietro / lsa_hack.r
Created September 3, 2013 23:03
playing with lsa based on post from http://goo.gl/ds2c4p
# script stolen from http://goo.gl/YbQyAQ
# install.packages("tm")
# install.packages("ggplot2")
# install.packages("lsa")
# install.packages("scatterplot3d")
#install.packages("SnowballC")
#if !(require('SnowballC')) then install.packages("SnowballC")
library(tm)
library(ggplot2)
@rpietro
rpietro / agile_principles.md
Created September 4, 2013 13:28
Key words or constructs summarizing Agile principles

Agile principles summarized in key words

  1. Customer focus: Our highest priority is to satisfy the customer through early and continuous delivery of valuable software.
  2. Adapting: Welcome changing requirements, even late in development. Agile processes harness change for the customer's competitive advantage.
  3. Working cycles: Deliver working software frequently, from a couple of weeks to a couple of months, with a preference to the shorter timescale.
  4. Teamwork: Business people and developers must work together daily throughout the project.
  5. Team support: Build projects around motivated individuals. Give them the environment and support they need, and trust them to get the job done.
  6. Communication: The most efficient and effective method of conveying information to and within a development team is face-to-face conversation.
  7. Functioning product: Working software is the primary measure of progress.
  8. Iterative cycles: Agile processe
install.packages("Rcpp")
install.packages("microbenchmark")
library(Rcpp)
library(microbenchmark)
#------------------------------------------------------------------------------
oneR <- function() 1L
one()
@rpietro
rpietro / parallelization_test.r
Created September 6, 2013 10:49
simple parallelization example
# part of this code from Thiele's http://goo.gl/Ed1zrq
# call packages
library(parallel)
library(microbenchmark)
#create simple function
testfun1 <- function(x) {
return(x*x)
@rpietro
rpietro / netlogo_hack.r
Created September 6, 2013 11:03
error with RNetLogo
sessionInfo()
# R version 3.0.1 (2013-05-16)
# Platform: x86_64-apple-darwin10.8.0 (64-bit)
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
# attached base packages:
# [1] stats graphics grDevices utils datasets methods base
@rpietro
rpietro / metaprogramming.r
Created September 6, 2013 23:49
metaprogramming example from http://goo.gl/fmIh4T
# script from http://goo.gl/fmIh4T
myFun <- function(vec) {
numElements <- length(which(vec > threshold))
numElements
}
genMyFuns <- function(thresholds) {
ll <- length(thresholds)
print("Generating functions:")