Back by popular (i.e., Wyatt's) demand

I will re-start summarizing the big picture ideas discussed in class. Below a brief recap:

The code we produced in the last three class periods can be downloaded and reviewed here:

Day 07

We discussed indexing both by location and by logical conditions:

x <- c(2, 4, 16)

x[2:3] # extracts the 2nd and 3rd element of x

x[x < 5] # extracts the 1st and 2nd element of x 

New functions we considered included print(), paste(..., sep = ""), and cat(). We also learned about the modulo operator %% as well as the escape charcter \ and the linebreal "\n".

Another useful new function was subset().


x <- c(3, 2, 1, 0, -1, -2, -3) 

subset(x, x > 0) # extracts from x all x greater than zero

Finally, we introduced the notion of factors (i.e., special integer type vectors with the attribute factor and levels).


x <- c("yes", "yes", "no")

x <- as.factor(x)

x

typeof(x)

summary(x)

Day 08

New functions include is.na() to querry NAs and na.omit() to subset objects such that NAs are excluded. Also discussed:

Day 09

Functions discussed included:

More complicated flow control:

if (1 + 1 == 2) {print("True")} else {print("False")}


if (0.5 > 1) {
	x <- rnorm(10)
	x[1]
	sum(x)
} else {
	y <- runif(10, 0, 1)
	y[1]
	sum(y)
}