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
# simulate some data | |
set.seed(88) | |
n <- 30 | |
x <- runif(n) | |
y <- 1.2 + 0.8*x + rnorm(n) | |
g <- sample(letters[1:2], n, replace=TRUE) | |
my.df <- data.frame(x=x, y=y, grp=factor(g)) | |
# show data structure | |
dput(my.df) |
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
mha <- 1 # mean under the alternative | |
es <- 2 # observed effect (deviation from mean under H0) | |
x <- seq(-6, 6, length=1000) | |
dh0 <- dnorm(x, 0, 1) | |
show.it <- function(es, mha, verbose=FALSE) { | |
dh1 <- dnorm(x, mha, 1) | |
plot.new() | |
plot.window(xlim=range(x), ylim=c(0,.6)) |
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
tufte.boxplot <- function(x, g) { | |
k <- nlevels(g) | |
crit.val <- tapply(x, g, median) | |
plot(1:k, crit.val, ylim=c(min(x)*1.1, max(x)*1.1), pch=19, | |
xlab=deparse(substitute(g)), ylab=deparse(substitute(x))) | |
for (i in 1:k) { | |
tmp <- boxplot.stats(x[as.numeric(g)==i]) | |
segments(i, tmp$stats[1], i, tmp$stats[2]) | |
segments(i, tmp$stats[4], i, tmp$stats[5]) | |
points(rep(i, length(tmp$out)), tmp$out, cex=.8) |
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
@article{Narrow2009, | |
Author = {Narrow, W.E. and Kuhl, E.A. and Regier, D.A.}, | |
Journal = {World Psychiatry}, | |
Month = {Jun}, | |
Number = {2}, | |
Pages = {88-89}, | |
Title = {{DSM-V} perspectives on disentangling disability from | |
clinical significance}, | |
Volume = {8}, | |
Year = {2009}} |
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
% compile with | |
% R CMD Sweave sweave_ggplot.Rnw | |
% pdflatex sweave_ggplot.tex | |
\documentclass[t,ucs,12pt,xcolor=dvipsnames]{beamer} | |
\usepackage{fancyvrb} | |
\title{A sample Sweave demo} | |
\author{Author name} | |
\date{} |
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
library(mixOmics) | |
library(RColorbrewer) | |
X <- replicate(6, rnorm(50)) | |
X.row.mds <- cmdscale(dist(X), k=1) | |
X.col.mds <- cmdscale(dist(t(X)), k=1) | |
cim(cor(X)[order(X.col.mds),order(X.col.mds)], col=rev(brewer.pal(8, "RdBu"))) | |
cim(cor(t(X))[order(X.row.mds),order(X.row.mds)], col=rev(brewer.pal(8, "RdBu"))) | |
cim(X, col=rev(brewer.pal(8, "RdBu")) |
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
display.cell <- function(x, bgcol="#DAE6F2", ...) { | |
opar <- par(bg=bgcol, mar=rep(0,4)) | |
plot(c(0,1), c(0,1), type="n", axes=FALSE, xlab="", ylab="") | |
text(.5, .5, as.character(x), ...) | |
lines(c(-0.1,1.1), c(0,0)) | |
par(opar) | |
} | |
format.digits <- function(x) as.character(paste("$", as.character(x), sep=" ")) |
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
@article{arlot2010survey, | |
Author = {Arlot, S. and Celisse, A.}, | |
Journal = {Statistics Surveys}, | |
Pages = {40--79}, | |
Title = {A survey of cross-validation procedures for model selection}, | |
Volume = {4}, | |
Year = {2010}} | |
@article{feinerer2008text, | |
Author = {Feinerer, I. and Hornik, K. and Meyer, D.}, |
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
x <- seq(0,10) | |
y <- seq(0,10) | |
df <- expand.grid(x=x, y=y) | |
df$z <- rnorm(nrow(df), mean=5) | |
library(lattice) | |
levelplot(z ~ x+y, data=df, | |
panel=function(x, y, ...) { | |
panel.levelplot(x, y, ...) | |
panel.abline(v=1) |
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
# Time-stamp: <2011-01-07 12:41:47 chl> | |
# | |
# Some illustrations of SQL joins with R. | |
# Inspiration: Jeff Atwood, http://bit.ly/eMhJEp | |
# | |
tableA <- data.frame(id=1:4, name=c("Pirate","Monkey","Ninja","Spaghetti")) | |
tableB <- data.frame(id=1:4, name=c("Rutabaga","Pirate","Darth Vader","Ninja")) |