Skip to content

Instantly share code, notes, and snippets.

@fototo
fototo / example-r-markdown.rmd
Created May 19, 2012 23:34 — forked from raffdoc/example-r-markdown.rmd
Example of using R Markdown
This post examines the features of [R Markdown](http://www.rstudio.org/docs/authoring/using_markdown)
using [knitr](http://yihui.name/knitr/) in Rstudio 0.96.
This combination of tools provides an exciting improvement in usability for
[reproducible analysis](http://stats.stackexchange.com/a/15006/183).
Specifically, this post
(1) discusses getting started with R Markdown and `knitr` in Rstudio 0.96;
(2) provides a basic example of producing console output and plots using R Markdown;
(3) highlights several code chunk options such as caching and controlling how input and output is displayed;
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and
(5) discusses the implications of R Markdown.
@fototo
fototo / caschools-analysis.rmd
Created May 19, 2012 23:34 — forked from raffdoc/caschools-analysis.rmd
California schools analysis demonstrating use of R Markdown
`r opts_chunk$set(cache=TRUE)`
This is a quick set of analyses of the California Test Score dataset. The post was produced using R Markdown in RStudio 0.96. The main purpose of this post is to provide a case study of using R Markdown to prepare a quick reproducible report. It provides examples of using plots, output, in-line R code, and markdown. The post is designed to be read along side the R Markdown source code, which is available as a gist on github.
<!-- more -->
### Preliminaries
* This post builds on my earlier post which provided a guide for [Getting Started with R Markdown, knitr, and RStudio 0.96](jeromyanglim.blogspot.com/2012/05/getting-started-with-r-markdown-knitr.html)
* The dataset analysed comes from the `AER` package which is an accompaniment to the book [Applied Econometrics with R](http://www.amazon.com/Applied-Econometrics-R-Use/dp/0387773169) written by [Christian Kleiber](http://wwz.unibas.ch/personen/profil/person/kleiber/) and [Achim Zeileis](http://eeecon.uibk.ac.at/~zeileis/
@fototo
fototo / performance summary.r
Created May 19, 2012 23:34 — forked from raffdoc/performance summary.r
performance summary RNW and R
require(knitr)
knit2pdf("performance summary.rnw")
@fototo
fototo / GreatCircleFlights.R
Created July 23, 2012 05:54 — forked from cengel/GreatCircleFlights.R
Great Circles in ggplot
library(maps)
library(geosphere)
library(plyr)
library(ggplot2)
library(sp)
airports <- read.csv("http://www.stanford.edu/~cengel/cgi-bin/anthrospace/wp-content/uploads/2012/03/airports.csv", as.is=TRUE, header=TRUE)
flights <- read.csv("http://www.stanford.edu/~cengel/cgi-bin/anthrospace/wp-content/uploads/2012/03/PEK-openflights-export-2012-03-19.csv", as.is=TRUE, header=TRUE)
# aggregate nunber of flights
@fototo
fototo / currencyplot.r
Created July 26, 2012 06:26 — forked from timelyportfolio/currencyplot.r
dendrogram grouped currency plot
require(quantmod)
require(fAssets)
#get asian currency data from the FED FRED data series
getSymbols("DEXKOUS",src="FRED") #load Korea
getSymbols("DEXMAUS",src="FRED") #load Malaysia
getSymbols("DEXSIUS",src="FRED") #load Singapore
getSymbols("DEXTAUS",src="FRED") #load Taiwan
getSymbols("DEXCHUS",src="FRED") #load China
getSymbols("DEXJPUS",src="FRED") #load Japan
#get very helpful Ken French data
#for this project we will look at Industry Portfolios
#http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip
require(latticeExtra)
require(animation)
require(PerformanceAnalytics)
require(quantmod)
#my.url will be the location of the zip file with the data
require(fAssets)
require(latticeExtra)
require(quantmod)
require(PerformanceAnalytics)
#my.url will be the location of the zip file with the data
my.url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip"
#this will be the temp file set up for the zip file
my.tempfile<-paste(tempdir(),"\\frenchindustry.zip",sep="")
#my.usefile is the name of the txt file with the data
#get very helpful Ken French data
#for this project we will look at Industry Portfolios
#http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip
require(latticeExtra)
require(PerformanceAnalytics)
require(quantmod)
#my.url will be the location of the zip file with the data
my.url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip"
#get very helpful Ken French data
#for this project we will look at Industry Portfolios
#http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip
require(latticeExtra)
require(PerformanceAnalytics)
require(quantmod)
#my.url will be the location of the zip file with the data
my.url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip"
@fototo
fototo / chartTimeSeries and chartsPerformanceSummary.r
Created August 17, 2012 12:23 — forked from timelyportfolio/chartTimeSeries and chartsPerformanceSummary.r
plot.xts replacements of PerformanceAnalytics chart.TimeSeries and charts.PerformanceSummary
require(PerformanceAnalytics)
#replicate example provided in chart.TimeSeries with plot.xts
# These are start and end dates, formatted as xts ranges.
## http://www.nber.org-cycles.html
cycles.begin.dates<-c("1857-06",
"1860-10",