Commits

Sean Davis committed d3b1a06

added simple R intro

Comments (0)

Files changed (3)

+### R code from vignette source 'RIntroBrief'
+
+###################################################
+### code chunk number 1: RIntroBrief.Rnw:14-22
+###################################################
+x = 1
+x
+y = rep('a',10)
+y
+z = rnorm(15)
+z
+z<0
+z[z<0]
+
+
+###################################################
+### code chunk number 2: RIntroBrief.Rnw:28-40
+###################################################
+m = matrix(rnorm(100),ncol=5)
+ncol(m)
+nrow(m)
+dim(m)
+summary(m)
+# first column of m
+m[,1]
+# first row of m
+m[1,]
+# get a big matrix from R
+data(volcano)
+dim(volcano)
+
+
+###################################################
+### code chunk number 3: RIntroBrief.Rnw:47-56
+###################################################
+cvec = rep(c('a','b'),each=10)
+cvec
+f = factor(cvec)
+f
+levels(f)
+# we can change the levels of the factor
+levels(f) = c('d','e')
+f
+as.character(f)
+
+
+###################################################
+### code chunk number 4: RIntroBrief.Rnw:61-67
+###################################################
+df = data.frame(m,f)
+dim(df)
+head(df)
+colnames(df)
+df$X1
+summary(df)
+
+
+###################################################
+### code chunk number 5: RIntroBrief.Rnw:74-75
+###################################################
+plot(df[,1],df[,2],col=df$f,pch=2,main='A simple plot')
+
+
+###################################################
+### code chunk number 6: RIntroBrief.Rnw:80-83 (eval = FALSE)
+###################################################
+## source('http://bioconductor.org/biocLite.R')
+## library(BiocInstaller)
+## biocLite(c('genefilter','qvalue'))
+
+
+###################################################
+### code chunk number 7: RIntroBrief.Rnw:88-89 (eval = FALSE)
+###################################################
+## help(package='genefilter')
+
+
+\documentclass{article}
+
+\title{A Very Brief Introduction to R}
+\author{Sean Davis}
+\date{June 21, 2013}
+
+\begin{document}
+
+\maketitle
+
+\section{Vectors}
+
+<<>>=
+x = 1
+x
+y = rep('a',10)
+y
+z = rnorm(15)
+z
+z<0
+z[z<0]
+@ 
+
+
+\section{Matrices}
+
+<<>>=
+m = matrix(rnorm(100),ncol=5)
+ncol(m)
+nrow(m)
+dim(m)
+summary(m)
+# first column of m
+m[,1]
+# first row of m
+m[1,]
+# get a big matrix from R
+data(volcano)
+dim(volcano)
+@ 
+
+\section{Factors}
+
+Remember that factors are used for storing categorical variables.  They often look like character vectors, but they do not have ``quotes'' when R prints them.  Also, they behave more like numeric vectors.
+
+<<>>=
+cvec = rep(c('a','b'),each=10)
+cvec
+f = factor(cvec)
+f
+levels(f)
+# we can change the levels of the factor
+levels(f) = c('d','e')
+f
+as.character(f)
+@ 
+
+\section{Data Frames}
+
+<<>>=
+df = data.frame(m,f)
+dim(df)
+head(df)
+colnames(df)
+df$X1
+summary(df)
+@ 
+
+\section{Plotting}
+
+This is where your curiosity and experimentation come in handy.  R has many plotting capabilities and some trial and error may be necessary to get what you want from R graphics.
+
+<<fig=true>>=
+plot(df[,1],df[,2],col=df$f,pch=2,main='A simple plot')
+@ 
+
+\section{Package installation}
+
+<<eval=FALSE>>=
+source('http://bioconductor.org/biocLite.R')
+library(BiocInstaller)
+biocLite(c('genefilter','qvalue'))
+@ 
+
+\subsection{Getting Help on a Package}
+
+<<eval=FALSE>>=
+help(package='genefilter')
+@ 
+
+
+\end{document}

RIntroBrief.pdf

Binary file added.