Skip to content

Instantly share code, notes, and snippets.

@jeromyanglim
jeromyanglim / rstudio-markdown-error.rmd
Created June 14, 2012 00:52
r markdown error in rstudio
* asdf
```{r}
'asdf'
```
@jeromyanglim
jeromyanglim / bibmash
Created June 10, 2012 11:37
script for extracting apa; I might write a post at some point about how it all works. it's mainly a personal script; it's very raw; use at own risk
#!/bin/bash
bibtexstylefile=apalike
bibtexdatabase=$BIB
pdfdirectory=$BIBDIR
pdfprogram=evince
pandocoutputformat=plain
# returntask
# bibtex : return bibtex record (default)
# format : return
This document is just a test of RPubs platform for publishing R Markdown. I'll use the `survey` dataset from the `MASS` package to explore a few features.
```{r get_data, message=FALSE}
library(MASS)
library(psych)
library(Hmisc)
library(xtable)
data(survey)
```
@jeromyanglim
jeromyanglim / loopsrmarkdown.html
Created May 22, 2012 23:45
example of loops and plots in R Markdown
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<base target="_blank"/>
@jeromyanglim
jeromyanglim / r-markdown-example.html
Created May 21, 2012 07:56
file produced by R Markdown example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
`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/
@jeromyanglim
jeromyanglim / example-r-markdown.rmd
Created May 17, 2012 04:23
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.
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/javascript">MathJax.Hub.Config({tex2jax: {processEscapes: true,
processEnvironments: false, inlineMath: [ ['$','$'] ],
displayMath: [ ['$$','$$'] ] },
asciimath2jax: {delimiters: [ ['$','$'] ] },
"HTML-CSS": {minScaleAdjust: 125 } });
</script>
@jeromyanglim
jeromyanglim / abilitytests.exp
Created May 11, 2012 05:56
Simple, 2-choice, and 4-choice reaction time experiment using Inquisit
<expt ability>
/preinstructions = (initial.instructions)
/blocks=[1=pm.simple; 2=pm.4choice; 3=ac.test.type]
</expt>
<data>
/columns=[date, time, build, subject, trialcode, blockcode, blocknum, trialnum, latency, response, pretrialpause,
posttrialpause, trialtimeout, blocktimeout, correct, stimulusitem, stimulusnumber,
display.height, display.width,
computer.cpuspeed, computer.os,
@jeromyanglim
jeromyanglim / 3catggplot2.r
Created May 3, 2012 12:10
plot with three categorical variables and one continuous variable using ggplot2
#http://jeromyanglim.blogspot.com.au/2012/05/how-to-plot-three-categorical-variables.html
library(ggplot2)
# Create some data
set.seed(4444)
Data <- expand.grid(group=c("Apples", "Bananas", "Carrots", "Durians", "Eggplants"),
year=c("2000", "2001", "2002"),
quality=c("Grade A", "Grade B", "Grade C", "Grade D", "Grade E"))
Group.Weight <- data.frame(
group=c("Apples", "Bananas", "Carrots", "Durians", "Eggplants"),