R for Statistical Computing (Chapter 6) R6.1 C6_height data C6_height is a data file in the workspace C6.RData. The first row in the file is the variable name H, and the other rows contain 40 numbers of heights (in cm). The following R commands perform the data input and computation of the mean and median (note that R is case sensitive). > attach(C6_height) > mean(H) [1] 161.375 > median(H) [1] 160.5 R6.2 C6_income data To generate a random sample of 60 observations from a normal population with mean 24 and standard deviation 6, use the following command > x = rnorm(n=60, mean=24, sd=6) Every time the above command is executed, a new sample of observations is created. The variable name used in data set C6_income is Y (income in thousand dollars). To check the results discussed in 6.2, do the following > > > > attach(C6_income) mean(Y) median(Y) sd(Y) R6.3 C6_time data The exponential distribution is described by only one parameter, which is called “rate” in R. As the exponential distribution is commonly used to describe the waiting time of occurrence of an event, rate is the mean number of occurrence of the event within a unit interval. Thus, if the observations are measured in minutes (hours), rate is the mean number of occurrence per minute (hour). To generate a random sample of 100 observations from an exponential population with rate 0.2, use the following command > x = rexp(n=100, rate=0.2) For the calculation of the mean, median and variance, use similar commands as in R6.1 and R6.2. The data set name is C6_time, and the variable name is T (for time in min). 1