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
| <!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> |
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
| <!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"/> |
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 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) | |
| ``` |
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
| #!/bin/bash | |
| bibtexstylefile=apalike | |
| bibtexdatabase=$BIB | |
| pdfdirectory=$BIBDIR | |
| pdfprogram=evince | |
| pandocoutputformat=plain | |
| # returntask | |
| # bibtex : return bibtex record (default) | |
| # format : return |
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
| * asdf | |
| ```{r} | |
| 'asdf' | |
| ``` |
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
| kbd{white-space:nowrap; | |
| color:#000; | |
| background:#eee; | |
| border-style:solid; | |
| border-color:#ccc #aaa #888 #bbb; | |
| padding:2px 6px; | |
| -moz-border-radius:4px; | |
| -webkit-border-radius:4px; | |
| border-radius:4px; | |
| -moz-box-shadow:0 2px 0 rgba(0, 0, 0, 0.2),0 0 0 1px #ffffff inset; |
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
| Sub CollapseHeadings() | |
| ' Use this code at your own risk | |
| ' It works for me. I use it in Word documents while in Outline View | |
| ' for documents set up with Outline View in mind | |
| ' Remember Ctrl + Pause Break will get break the program | |
| On Error GoTo ErrorHandler | |
| Dim r As Range, o As Integer, p As Long, f As Boolean | |
| Dim currentOutlineLevel, nextOutlineLevel | |
| Dim timeout As Integer ' used to pre | |
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
| charnum2num <- function(x) { | |
| # Purpose | |
| # Take a data.frame x and convert all columns of class character that appear to be numeric into numeric | |
| # x is a data.frame | |
| # code taken from library(Hmisc) and included here to avoid the dependency | |
| all.is.numeric <- function (x, what = c("test", "vector"), extras = c(".", "NA")) | |
| { | |
| what <- match.arg(what) | |
| old <- options(warn = -1) | |
| on.exit(options(old)) |
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
| freqtable <- function(X) { | |
| # X: data.frame of typically survey items | |
| # Code assumes that all items are numeric (i.e., 1 to 5, rather than text labels) | |
| unique_values <- unique(unlist(sapply(X, unique))) | |
| su <- sort(unique_values) | |
| freq <- t(sapply(X, function(Z) table(factor(Z, su)))) | |
| prop <- t(sapply(X, function(Z) prop.table(table(factor(Z, su))))) | |
| list(freq = freq, prop = prop) | |
| } |