The following is a script file containing all R code of all sections in this chapter.
m1 <- matrix(c(45, 23, 66, 77, 33, 44, 56, 12, 78, 23), 2, 5)
cbind(c(4, 76), m1[, 4])
m2 <- matrix(rep(10, 20), 4, 5)
m2
m3 <- rbind(m1[1, ], m2[3, ])
m3
my.dataset <- data.frame(site=c('A','B','A','A','B'),
season=c('Winter','Summer','Summer','Spring','Fall'),
pH = c(7.4,6.3,8.6,7.2,8.9))
my.dataset
my.dataset[my.dataset$pH > 7, ]
my.dataset[my.dataset$site == "A", "pH"]
my.dataset[my.dataset$season == "Summer", c("site", "pH")]