This file contains hidden or 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
#get very helpful Ken French data | |
#for this project we will look at Global Factors | |
#http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/Global_Factors.zip | |
require(PerformanceAnalytics) | |
require(quantmod) | |
require(RColorBrewer) | |
#my.url will be the location of the zip file with the data |
This file contains hidden or 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
library(ggplot2) | |
library(colorRamps) | |
TawiTawiPop <- c(17000, 45000, 46000, 59000, 79000, 110000, 143000, 195000, 228204, | |
250718, 322317, 450346, 366550) | |
YearNames <- c("1903", "1918", "1939", "1948", "1960", "1970", "1975", "1980", "1990", | |
"1995", "2000", "2007", "2010") | |
qplot(YearNames, TawiTawiPop, | |
xlab = expression(bold("Censal Year")), |
This file contains hidden or 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
source('pubmed_trend.r') | |
sex.pub <- pubmed_trend(search.str = 'Sex+Characteristics[mh] AND Pain[mh]', year.span=1970:2011) | |
analgesic.pub <- pubmed_trend(search.str = 'Sex+Characteristics[mh] AND Analgesics[mh]', year.span=1970:2011) | |
source('plot_bar.r') | |
library("RColorBrewer") | |
pdf(file='sex_pain.pdf', height=8, width=8) | |
par(las=1) | |
colorfunction = colorRampPalette(brewer.pal(9, "Reds")) |
This file contains hidden or 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
library(ggplot2) | |
library(colorRamps) | |
IliganCity <- c(104493, 118778, 167358, 226568, 273004, 285061, 308046, 322821) | |
CensalYear <- c("1970", "1975", "1980", "1990", "1995", "2000", "2007", "2010") | |
qplot(CensalYear, IliganCity, xlab = expression(bold("Censal Year")), | |
ylab = expression(bold("Population")), geom = "bar", colour = I("red"), | |
fill = IliganCity, stat = "identity", ylim = c(0, 370000)) + theme_bw() + | |
opts( |
This file contains hidden or 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
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. |
This file contains hidden or 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
`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/ |
This file contains hidden or 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{article} | |
%great guides at epslatex.pdf | |
%check miniplot for potential use | |
\usepackage{graphics} | |
\usepackage{caption} | |
%\usepackage{sidecap} | |
%\usepackage{textpos} | |
\usepackage[section]{placeins} |
This file contains hidden or 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
Interactive charts and slides with R, googleVis and knitr | |
======================================== | |
```{r results='asis', echo=FALSE, message=FALSE, tidy=FALSE} | |
library(googleVis) | |
G <- gvisGeoChart(Exports, "Country", "Profit", | |
options=list(width=250, height=120), chartid="c1") | |
T <- gvisBarChart(Exports[,1:2], yvar="Profit", xvar="Country", | |
options=list(width=250, height=260, | |
legend='none'), chartid="c2") |
This file contains hidden or 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[nohyper,justified]{tufte-handout} | |
%\documentclass{article} | |
%great guides at epslatex.pdf | |
%check miniplot for potential use | |
%\usepackage{graphics} | |
%\usepackage{caption} | |
%\usepackage{sidecap} | |
%\usepackage{textpos} | |
%\usepackage[section]{placeins} |
This file contains hidden or 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
# Script name: instant_pkgs.R | |
# Purpose: Package installation and loading | |
# Author: Kay Cichini | |
# Date: 2012-06-19 | |
# Licence: cc by-nc-sa | |
instant_pkgs <- function(pkgs) { | |
pkgs_miss <- pkgs[which(!pkgs %in% installed.packages()[, 1])] | |
if (length(pkgs_miss) > 0) { | |
install.packages(pkgs_miss) |