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
| % 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 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(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 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
| 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 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
| @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 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
| 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 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
| # 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")) |
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
| prologues := 2; | |
| input geometriesyr16; | |
| figure(-u,-u,6.5u,6u); | |
| pair A,B,C,D,E,F,G,H,I,J,K,L,M,N; | |
| picture depart; | |
| numeric i,j,r,v; | |
| r:=.5; |
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
| # Time-stamp: <2010-12-10 14:28:19 chl> | |
| # | |
| # A toy example to illustrate SS idea in the Linear Model. | |
| # | |
| do.it <- function(x, g) { | |
| stopifnot(is.factor(g)) | |
| stripchart(x ~ g, method="jitter", pch=19, col="darkgrey", | |
| vertical=TRUE, ylab="") |
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
| # Some examples of graphical displays for Likert items | |
| # | |
| # Time-stamp: <2010-10-24 20:04:59 chl> | |
| data(Environment, package="ltm") | |
| Environment[sample(1:nrow(Environment), 10),1] <- NA | |
| na.count <- apply(Environment, 2, function(x) sum(is.na(x))) | |
| tab <- apply(Environment, 2, table)/apply(apply(Environment, 2, table), 2, sum)*100 | |
| # Cleveland dot plot | |
| dotchart(tab, xlim=c(0,100), xlab="Frequency (%)", sub=paste("N", nrow(Environment), sep="="), pch=19) |
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
| itan <- function(x, keys=NULL, digits=3, no.resp=4) { | |
| # x is an n subjects by k items matrix | |
| # keys is a vector with the correct keys (A, B, C, D) | |
| stopifnot(ncol(x)>1) | |
| if (is.null(keys)) keys <- rep("A", ncol(x)) | |
| require(ltm) | |
| raw.resp <- matrix(nr=ncol(x), nc=no.resp) | |
| colnames(raw.resp) <- LETTERS[1:no.resp] | |
| for (i in 1:ncol(x)) { | |
| tmp <- table(x[,i]) |