QUIZ 1 (questions are in italics) This quiz deals with the different ways of reading data into R, histograms of data, and their shape. If you've done the prelab, and I hope you have, you'll know how to read data into R, when I say the data "is on the course website" even though there is no visible link to that data set on the course website. If you don't know, read the sentence on the course website that states "All required data sets ..." a) Write code to read-in the data set called qz1_dat.txt from the course website, and call it dat. The data set has no header. dat = read.table("http://sites.stat.washington.edu/marzban/390/spring21/qz1_dat.txt",header=F) b) Write code to make a (frequency) histogram of the 2nd column, with about 50 breaks. hist(dat[,2], breaks = 50) c) Write code to make a (frequency) histogram of the (natural) log of the 2nd column, with about 50 breaks. hist(log(dat[,2]), breaks=50) d) Write code to make a (frequency) histogram of the length of teeth in the R data called ToothGrowth, with about 20 breaks. data(ToothGrowth) # for some students, this is unnecessary. hist(ToothGrowth$len, breaks=20) e) Consider the data (0, 0, 1, 0, 1, 0, 1, 0, 1, 0). Write code to make a histogram for this data. Do not make a text file containing this data. x = c(0, 0, 1, 0, 1, 0, 1, 0, 1, 0) hist(x) Morals: 1) There are three ways of reading data into R; know all three. 2) The shape of a histogram can be changed by considering transformations. In particular, we often try different transformations (e.g., log, sqrt, ...) that make the histogram have some desired shape, e.g., bell-shaped, or linear. # Confession: I made that data this way (you will learn these things later): set.seed(123) x1 = rexp(5000,2) x2 = rlnorm(5000) write(rbind(x1,x2),ncol=2,file="qz1_dat.txt")