Problem Set # 2

Due Date: October 14, 2022 Total Points: 32

1 The following ten observations, taken during the years 1970-1979, are on October snow cover for Eurasia in units of millions of square kilometers. Follow the instructions and answer the questions by typing the appropriate commands.

Year Snow 1970 6.5 1971 12.0 1972 14.9 1973 10.0 1974 10.7 1975 7.9 1976 21.9 1977 12.5 1978 14.5 1979 9.2

  1. Create a data frame from these data. (2)
Year = c(1970:1979)
Snow = c(6.5, 12, 14.9, 10, 10.7, 7.9, 21.9, 12.5, 14.5, 9.2)
Oct.Snow = data.frame(Year, Snow)
  1. What are the mean and median snow cover over this decade? (2)
mean(Oct.Snow$Snow)
## [1] 12.01
median(Oct.Snow$Snow)
## [1] 11.35
  1. What is the standard deviation of the snow cover over this decade? (2)
sd(Oct.Snow$Snow)
## [1] 4.390761
  1. How many Octobers had snow cover greater than 10 million km\(^2\)? (2)
length(which(Oct.Snow$Snow > 10))
## [1] 6

2 The data vector rivers contains the lengths (miles) of 141 major rivers in North America.

  1. What proportion of the rivers are shorter than 500 miles long? (2)
length(which(rivers < 500))/length(rivers)
## [1] 0.5815603
  1. What proportion of the rivers are shorter than the mean length? (2)
length(which(rivers < mean(rivers)))/length(rivers)
## [1] 0.6666667
  1. What is the 75th percentile river length? (2)
quantile(sort(rivers), probs = 0.75)
## 75% 
## 680
  1. What is the interquartile range in river length? (2)
IQR(rivers)
## [1] 370

3 The dataset hflights from the hflights package contains all 227,496 flights that departed Houston in 2011. Using the functions in the dplyr package

  1. Create a data frame from hflights containing only those flights that departed on September 11th of that year. (4)

  2. How many flights departed on that day? (2)

  3. Create a data frame with the first column being the tail number and the second being the number of departures from Houston the plane made that year sorted by most to least number of flights. (4)

4 Using the tornado data set (Canvas - Tornadoes.txt) create a data frame with the year in the first column and the total number of tornadoes in Kansas by year in the second column. (6)