date()
## [1] "Mon Sep 30 22:39:38 2024"
require(spgwr)
## Loading required package: spgwr
## Loading required package: sp
## Loading required package: spData
## To access larger datasets in this package, install the spDataLarge
## package with: `install.packages('spDataLarge',
## repos='https://nowosad.github.io/drat/', type='source')`
## NOTE: This package does not constitute approval of GWR
## as a method of spatial analysis; see example(gwr)
Due Date: September 18, 2022
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
canes = c(0, 1, 1, 1, 0, 2, 2, 1, 3, 3, 0, 0, 1, 2, 6, 6, 0, 1, 3, 0, 1)
length(canes)
## [1] 21
sum(canes)
## [1] 34
2 Answer the following questions by typing R commands.
quarter = c(0:25)
quarter
## [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
## [26] 25
length(quarter)
## [1] 26
mean(quarter)
## [1] 12.5
l = quarter[]-mean(quarter)
l
## [1] -12.5 -11.5 -10.5 -9.5 -8.5 -7.5 -6.5 -5.5 -4.5 -3.5 -2.5 -1.5
## [13] -0.5 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5
## [25] 11.5 12.5
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)
y = diff(miles)
y
## [1] 313 284 311 280 322 324 302
max(y)
## [1] 324
min(y)
## [1] 280
mean(y)
## [1] 305.1429
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 47 49
## [26] 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99
rep(c(1,2,3),c(3,3,3))
## [1] 1 1 1 2 2 2 3 3 3
rep(c(1,2,3),c(3,2,1))
## [1] 1 1 1 2 2 3
5 Read the monthly precipitation dataset from my website (https://moraviansoundscapes.music.fsu.edu/sites/g/files/upcbnu1806/files/Media/Sciuchetti/ALMonthlyP.txt).
loc = "https://moraviansoundscapes.music.fsu.edu/sites/g/files/upcbnu1806/files/Media/Sciuchetti/ALMonthlyP.txt"
G = read.table(file = loc, header = TRUE)
head(G)
## Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
## 1 1895 7.37 1.41 7.17 2.72 3.06 4.04 4.58 4.00 3.41 2.28 1.83 5.83
## 2 1896 2.47 7.46 6.23 4.34 2.92 4.50 3.78 1.94 2.67 1.59 6.20 1.32
## 3 1897 3.85 3.74 14.40 4.99 2.87 2.12 3.93 3.66 0.03 1.74 2.13 8.54
## 4 1898 7.07 1.34 4.43 4.29 1.86 2.61 5.52 3.67 2.83 3.72 3.55 2.43
## 5 1899 5.79 6.39 9.93 2.99 1.50 2.22 6.04 3.44 0.57 1.85 3.93 7.28
## 6 1900 3.64 4.92 4.17 10.56 3.86 12.40 4.64 2.26 2.76 6.40 3.44 3.25
max(G$Jan)
## [1] 13.09
min(G$Jan)
## [1] 0.8
sort(G$Feb,decreasing = TRUE)
## [1] 13.35 12.16 11.42 10.69 10.18 10.13 9.85 9.58 9.26 9.23 9.08 8.76
## [13] 8.60 8.57 8.46 8.24 8.13 7.89 7.80 7.56 7.50 7.46 7.14 7.05
## [25] 7.02 6.70 6.64 6.57 6.56 6.56 6.39 6.12 6.10 6.09 6.04 6.02
## [37] 5.90 5.80 5.63 5.59 5.56 5.49 5.29 5.17 5.13 5.08 5.04 5.04
## [49] 5.02 4.98 4.94 4.92 4.89 4.84 4.80 4.75 4.74 4.69 4.53 4.52
## [61] 4.47 4.43 4.41 4.39 4.38 4.34 4.32 4.31 4.27 4.26 4.23 4.11
## [73] 4.05 3.94 3.87 3.82 3.81 3.74 3.73 3.72 3.68 3.60 3.60 3.60
## [85] 3.56 3.56 3.53 3.46 3.43 3.40 3.37 3.35 3.25 3.24 3.24 3.22
## [97] 3.21 3.16 3.13 3.00 2.92 2.91 2.82 2.73 2.71 2.69 2.60 2.52
## [109] 2.48 2.45 2.39 2.37 2.29 2.23 2.14 2.09 1.86 1.45 1.41 1.39
## [121] 1.34 1.32 1.29 1.25 0.76
var(G$Mar)
## [1] 7.41769
quantile(G$Apr, probs = .95)
## 95%
## 10.21
library(ggplot2)
ggplot(G, aes(x = Year, y = Apr)) +
geom_line()+
ylab("April Rainfall (in)")