date()
## [1] "Tue Sep 20 22:20:31 2016"
Due Date: September 20, 2016
Total Points: 42
1 The following values are the annual number hurricanes that have hit the United States since 1990. Answer the questions by typing R commands.
0 1 1 1 0 2 2 1 3 3 0 0 1 2 6 6 0 1 3 0 1
hits<-c(0,1,1,1,0,2,2,1,3,3,0,0,1,2,6,6,0,1,3,0,1)
length(hits)
## [1] 21
b = 21
sum(hits)
## [1] 34
c=34
2 Answer the following questions by typing R commands.
seq1<- (seq(from = 0, to = 25, by = 1))
length(seq1)
## [1] 26
b = 26
seqoriginal<- seq1
seq2 <- seq1
mean(seq2)
## [1] 12.5
seq2 = seq1-mean(seq1)
3 Suppose you keep track of your mileage each time you fill your car’s gas tank. At your last 8 fill-ups the mileage was
65311 65624 65908 66219 66499 66821 67145 67447
miles<- c(65311,65624,65908,66219,66499,66821,67145,67447)
ford<- diff(miles)
[1] 313 284 311 280 322 324 302
mean(ford)
## [1] 305.1429
max(ford)
## [1] 324
min(ford)
## [1] 280
mean(ford) [1] 305.1429 max(ford) [1] 324 min(ford) [1] 280
4 Create the following sequences using the seq() and rep() functions as appropriate.
rep("a", 4)
## [1] "a" "a" "a" "a"
seq(1,100, by=2)
## [1] 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45
## [24] 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91
## [47] 93 95 97 99
rep(1:3, each=3)
## [1] 1 1 1 2 2 2 3 3 3
rep(1:3, c(3,2,1))
## [1] 1 1 1 2 2 3
c(1:5,4:1)
## [1] 1 2 3 4 5 4 3 2 1
5 Read the monthly precipitation dataset from my website (http://myweb.fsu.edu/jelsner/temp/data/FLMonthlyP.txt).
loc<- "http://myweb.fsu.edu/jelsner/temp/data/FLMonthlyP.txt"
mdata<- read.table(file = loc, header = TRUE)
range(mdata$Jan)
## [1] 0.34 8.36
min = 0.34, max = 8.36
sort(mdata$Feb, decreasing=TRUE)
## [1] 8.58 7.46 6.71 6.00 5.92 5.78 5.65 5.58 5.46 5.46 5.42 5.38 5.11 4.96
## [15] 4.87 4.81 4.76 4.73 4.67 4.58 4.57 4.48 4.37 4.31 4.27 4.26 4.24 4.21
## [29] 4.18 4.18 4.17 4.09 4.03 4.00 3.96 3.94 3.92 3.92 3.92 3.81 3.79 3.72
## [43] 3.60 3.57 3.55 3.55 3.52 3.51 3.44 3.39 3.36 3.36 3.32 3.30 3.24 3.22
## [57] 3.17 3.17 3.17 3.15 3.10 3.04 3.03 3.02 3.02 2.99 2.94 2.74 2.74 2.72
## [71] 2.71 2.60 2.60 2.54 2.50 2.49 2.48 2.36 2.34 2.32 2.30 2.30 2.22 2.16
## [85] 2.15 2.14 2.11 2.11 2.06 2.01 2.01 1.99 1.97 1.85 1.84 1.82 1.81 1.78
## [99] 1.76 1.69 1.60 1.59 1.50 1.39 1.39 1.38 1.35 1.30 1.28 1.25 1.19 1.17
## [113] 1.14 1.12 1.07 0.95 0.85 0.80 0.74 0.29
var(mdata$Mar)
## [1] 3.767958
quantile(mdata$Apr, c(0.95))
## 95%
## 5.4515
d= 3.767958
library("ggplot2")
ggplot(mdata, aes(x = Year, y = Apr)) +
geom_line() +
ylab("April Precipitation in Florida (in)")