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
####################################################### | |
# 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 |
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
\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. |
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
# 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 |
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
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] |
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
#analyze asset allocation experience in Spain | |
require(lattice) | |
require(latticeExtra) | |
require(reshape2) | |
require(directlabels) | |
require(quantmod) | |
require(PerformanceAnalytics) | |
require(RQuantLib) |
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
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 |
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
# 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)) |
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
# 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) |
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
svmComputeOneForecast = function( | |
id, | |
data, | |
response, | |
startPoints, | |
endPoints, | |
len, | |
history=500, | |
trace=FALSE, | |
kernel="radial", |
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 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) |
OlderNewer