- Project 1 is due on the 24th
- No class on Tuesday (study section)
- Read The Art of R Programming (Chapters 4 and 5)
Patrick D. Schloss, PhD (microbialinformatics.github.io)
Department of Microbiology & Immunology
k
, chi.sq
, and iters
The default value for iters
should be 1000
When you do the following:
pchisq.rand(k=4, chi.sq=2, iters=10000)
x <- c(1,2,3)
or
x <- 1:3
x <- 3:1
or
x <- seq(1,3,1)
x <- vector(length=3)
x[1] <- 1
x[2] <- 2
x[3] <- 3
x<- c(x, c(1,2,3))
or
x<- rep(c(1,2,3), 2)
x[5] #remember vector indices start at 1
x[5,1] #is this correct?
v<-3:4
x[v]
x[length(x)]
x[-4]
x[-length(x)]
x[-c(1,2)]
names(x) <- c("a", "b", "c", "d", "e", "f")
x["e"]
c(1,2,4) + c(6,0,9,20,22) #how does R read this expression? what does it equal?
x <- rep(1:3,2)
x > 1
which(x>1)
subset(x, x>1)
x[x>1]
ifelse(x > 1, "dog", "cat")
ifelse(x > 1, x, x^2)
z <- seq(1:10)
ifelse(z>7, "C", ifelse(z>4, "B",ifelse(z>0, "A")))
x <- seq(1:3)
y <- seq(3:5)
x>y
x+5
x+y
x^2
sqrt(x) #many built in functions return vectors
z <- matrix(c(1,2,3,4,5,6), ncol=2) #fills by columns
z <- matrix(c(1,2,3,4,5,6), nrow=2) #fills by columns
z <- matrix(c(1,2,3,4,5,6), nrow=2, byrow=T) #fills by rows
length(z) #why?
dim(z)
nrow(z)
ncol(z)
colnames(z) <- c("a", "b", "c")
rownames(z) <- c("d", "e")
z[1,3]
z[2,]
z[,2:3]
z[,-1]
y <- matrix(c(1,2,3,4), ncol=2)
y * 2
y * y
y %*% y
apply(y, 1, sum)
apply(y, 2, sum)