# Chapter 2 R code examples: barplot(height=c(108,34,40), names.arg=c("Red","Pink","White"), main="Poinsettias", xlab="Colors", ylab="Frequency") piglets = c(5,7,7,8,8,8,9,9,9,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,13,12,12,14,14) hist(piglets) hist(piglets, right=FALSE)  # uses LEFT endpoints hist(piglets, right=FALSE, breaks=5:15)   # has bins that are 1 unit in length starting with 5 and ending with 15. hist(piglets, right=FALSE, breaks=5:15, main="Surviving Piglets", xlab="Number of Surviving Piglets")   # adds title and label length = c(rep(15,1), rep(16,3), rep(17,21), rep(18,27), rep(19,23), rep(20,15), rep(21,10), rep(22,15), rep(23,19), rep(24,21), rep(25,34), rep(26,44), rep(27,36), rep(28,41), rep(29,48), rep(30,28), rep(31,43), rep(32,27), rep(33,23), rep(34,10), rep(35,4), rep(36,5), rep(37,1), rep(38,1)) hist(length, breaks=15:38) hist(length, breaks=seq(15,39,by=2)) # has bins with width 2 rather than width 1 radish = c(3,5,5,7,7,8,9,10,10,10,10,14,20,21) summary(radish, quantile.type=2) boxplot(radish) bulls=c(1.18,1.24,1.29,1.37,1.41,1.51,1.58,1.72, 1.20,1.26,1.33,1.37,1.41,1.53,1.59,1.76, 1.23,1.27,1.34,1.38,1.44,1.55,1.64,1.83, 1.23,1.29,1.36,1.40,1.48,1.57,1.64,1.92, 1.23,1.29,1.36,1.41,1.50,1.58,1.65) mean(bulls) sd(bulls)