Exercises 21 cut(x,breaks,right=TRUE) Divide up the range of x into intervals and code the values in x according to which inter- val they fall into. require(fastR) require(lattice) require(Hmisc) Load packages. histogram(~x|z,data,...) Histogram of x conditioned on z. bwplot(x~z,data,...) Boxplot of x conditioned on z. xyplot(y~x|z,data,...) Scatterplot of y by x conditioned on z. stem(x) Stemplot of x. sum(x) mean(x) median(x) var(x) sd(x) quantile(x) Sum, mean, median, variance, standard devi- ation, quantiles of x. summary(y~x,data,fun) Summarize y by computing the function fun on each group defined by x [Hmisc]. Exercises 1.1. Read as much of Appendix A as you need to do the exercises there. 1.2. The pulse variable in the littleSurvey data set contains self-reported pulse rates. a) Make a histogram of these values. What problem does this histogram reveal? b) Make a decision about what values should be removed from the data and make a histogram of the remaining values. (You can use the subset argument of the histogram() function to restrict the data or you can create a new vector and make a histogram from that.) c) Compute the mean and median of your restricted set of pulse rates. 1.3. The pulse variable in the littleSurvey data set contains self-reported pulse rates. Make a table or graph showing the distribution of the last digits of the recorded pulse rates and comment on the distribution of these digits. Any conjec- tures? Note: %% is the modulus operator in R. So x %% 10 gives the remainder after dividing x by 10, which is the last digit. 1.4. Some students in introductory statistics courses were asked to select a num- ber between 1 and 30 (inclusive). The results are in the number variable in the littleSurvey data set.
Previous Page Next Page