Skip to content

Instantly share code, notes, and snippets.

View gwd999's full-sized avatar
🕶️

Walter D. gwd999

🕶️
View GitHub Profile
@sckott
sckott / taxize_rgbif_eg.R
Created November 1, 2011 00:23
Example of using taxize and rgbif packages together.
#######################################################
# by Scott Chamberlain <myrmecocystus@gmail.com>
# for blog post titled "Awesome use case: check my species names and
# gimme some distribution data"
#######################################################
# Load packages
install.packages(c("RCurl","stringr","XML","plyr","RJSONIO"))
require(RCurl);require(stringr);require(XML);require(plyr);require(RJSONIO)
# Clone taxize and rgbif repositories from GitHub
@psychemedia
psychemedia / bowelCancer.Rnw
Created November 1, 2011 10:54
Sweave script documenting the production of a funnel plot
\documentclass[a4paper]{article}
\SweaveOpts{echo=FALSE, keep.source=TRUE}
\usepackage{a4wide}
\usepackage{color}
\usepackage{hyperref}
\begin{document}
\section{Example of self-documenting data journalism notes}
This is an example of using Sweave to combine code and output from the R statistical programming environment and the LaTeX document processing environment to generate a self-documenting script in which the actual code used to do stats and generate statistical graphics is displayed along the charts it directly produces.
@gimoya
gimoya / jpeg_transparency.R
Created December 12, 2011 10:50
function for adding transparency to a jpeg-image
# file: jpeg_transparency.R
# purpose: add transparency to jpeg
# author: kay cichini
# arguments: path_to_jpeg, path_to_outfile, alpha (transparency 0-1)
# path_to_outfile defaults to default home directory
# alpha defaults to 0.5
# packages used: jpeg, png
# input: a jpeg image
# output: a png image
require(lattice)
require(latticeExtra)
require(reshape2)
require(directlabels)
require(quantmod)
require(PerformanceAnalytics)
getSymbols("^GSPC",from="1900-01-01")
GSPC.monthly <- GSPC[endpoints(GSPC,"months"),4]
@timelyportfolio
timelyportfolio / spainallocation.r
Created July 24, 2012 18:28
spain stocks and bonds
#analyze asset allocation experience in Spain
require(lattice)
require(latticeExtra)
require(reshape2)
require(directlabels)
require(quantmod)
require(PerformanceAnalytics)
require(RQuantLib)
require(PerformanceAnalytics)
require(quantmod)
getSymbols("^GSPC", from = "1900-01-01")
#get return series from closing price
ret.bh <- ROC(GSPC[,4],n = 1,type = "discrete")
#change first value from NA to 0
ret.bh[1,] <- 0
@dsparks
dsparks / str example.R
Created September 10, 2012 02:46
Illustrating the use of str()
# Let's say you want to display a table of model coefficients
# in order of their significance,
# and you want to plot the distribution of model residuals,
# but you don't know how to access these values.
# Use str().
# Generate some random data
NN <- 1000
theData <- data.frame(Alpha = rnorm(NN),
Beta = rnorm(NN))
@dsparks
dsparks / Binarize_categories.R
Created September 18, 2012 22:39
Categorical data to indicator matrix to log odds ratios
# Starting with categorical data, ending with a table of log odds ratios
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("plyr", "reshape2")
if(doInstall){install.packages(toInstall,
repos = "http://cran.us.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Canonical example of categorical data
HEC <- melt(HairEyeColor)
@gwd999
gwd999 / e1071.R
Created December 2, 2012 21:01 — forked from ivannp/e1071.R
Back-testing SVM with e1071
svmComputeOneForecast = function(
id,
data,
response,
startPoints,
endPoints,
len,
history=500,
trace=FALSE,
kernel="radial",
@abarbour
abarbour / rlpspec_allbench.R
Last active December 10, 2015 08:48
Add rowwise summary lines to ggplot2::facet_grid style plots.
# Add rowwise summary lines to ggplot2::facet_grid style plots.
# Andy Barbour
# geokook.wordpress.com
# December 2012
## clear workspace
rm(list=ls())
library(multitaper)
library(rbenchmark)