#Here’s a full description of all the columns: #• name: Storm name #• year, month, and day: Date of report #• hour: Hour of report (in UTC) #• lat: Latitude #• long: Longitude #• status: Storm classification (Tropical Depression, Tropical Storm, or Hurricane) #• category: Saffir-Simpson storm category (estimated from wind speed. -1 = Tropical Depression, 0 = Tropical Storm) #• wind: storm’s maximum sustained wind speed (in knots) #• pressure: Air pressure at the storm’s center (in millibars) #• ts_diameter: Diameter of the area experiencing tropical storm strength winds (34 knots or above) #• hu_diameter: Diameter of the area experiencing hurricane strength winds (64 knots or above)

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
glimpse(storms)
## Rows: 19,537
## Columns: 13
## $ name                         <chr> "Amy", "Amy", "Amy", "Amy", "Amy", "Amy",…
## $ year                         <dbl> 1975, 1975, 1975, 1975, 1975, 1975, 1975,…
## $ month                        <dbl> 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,…
## $ day                          <int> 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 2…
## $ hour                         <dbl> 0, 6, 12, 18, 0, 6, 12, 18, 0, 6, 12, 18,…
## $ lat                          <dbl> 27.5, 28.5, 29.5, 30.5, 31.5, 32.4, 33.3,…
## $ long                         <dbl> -79.0, -79.0, -79.0, -79.0, -78.8, -78.7,…
## $ status                       <fct> tropical depression, tropical depression,…
## $ category                     <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ wind                         <int> 25, 25, 25, 25, 25, 25, 25, 30, 35, 40, 4…
## $ pressure                     <int> 1013, 1013, 1013, 1013, 1012, 1012, 1011,…
## $ tropicalstorm_force_diameter <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
## $ hurricane_force_diameter     <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N…

#Table containing the name and year of storms recorded during the 1980s (i.e. from 1980 to 1989)

storm_names_1980s <- storms %>%
  filter(year >= 1980 & year < 1990) %>%
  select(name, year)

storm_names_1980s
## # A tibble: 2,674 × 2
##    name   year
##    <chr> <dbl>
##  1 Allen  1980
##  2 Allen  1980
##  3 Allen  1980
##  4 Allen  1980
##  5 Allen  1980
##  6 Allen  1980
##  7 Allen  1980
##  8 Allen  1980
##  9 Allen  1980
## 10 Allen  1980
## # ℹ 2,664 more rows

#2005 is the year with the most storms registered in the seam calendar.

storms_per_year <- storms %>%
  group_by(year) %>%
  summarise(storm_count = n())
storms_per_year
## # A tibble: 48 × 2
##     year storm_count
##    <dbl>       <int>
##  1  1975         238
##  2  1976         126
##  3  1977          92
##  4  1978         152
##  5  1979         324
##  6  1980         335
##  7  1981         311
##  8  1982         111
##  9  1983          88
## 10  1984         342
## # ℹ 38 more rows

#Table containing columns: 1) name of storm, 2) year of storm, and 3) count for number of records (of the corresponding storm)

storm_records_per_year <- storms %>%
  group_by(name, year) %>%
  summarise(record_count = n())
## `summarise()` has grouped output by 'name'. You can override using the
## `.groups` argument.
storm_records_per_year
## # A tibble: 655 × 3
## # Groups:   name [260]
##    name      year record_count
##    <chr>    <dbl>        <int>
##  1 AL011993  1993           11
##  2 AL012000  2000            4
##  3 AL021992  1992            5
##  4 AL021994  1994            6
##  5 AL021999  1999            4
##  6 AL022000  2000           12
##  7 AL022001  2001            5
##  8 AL022003  2003            4
##  9 AL022006  2006           13
## 10 AL031987  1987           32
## # ℹ 645 more rows

#Unique type of storms status

storm_status <- storms %>%
  distinct(status)

storm_status
## # A tibble: 9 × 1
##   status                
##   <fct>                 
## 1 tropical depression   
## 2 tropical storm        
## 3 extratropical         
## 4 hurricane             
## 5 subtropical storm     
## 6 subtropical depression
## 7 disturbance           
## 8 other low             
## 9 tropical wave

#There are 5 different type of categories for storms, 1 being the lowest and 5 the highest

storm_categories <- storms %>%
  distinct(category)

storm_categories
## # A tibble: 6 × 1
##   category
##      <dbl>
## 1       NA
## 2        1
## 3        3
## 4        2
## 5        4
## 6        5

#table containing the name and year of those storms of category 5.

storms_categ5 <- storms %>%
  filter(category == 5) %>%
  select(name, year)

storms_categ5
## # A tibble: 116 × 2
##    name   year
##    <chr> <dbl>
##  1 Anita  1977
##  2 Anita  1977
##  3 David  1979
##  4 David  1979
##  5 David  1979
##  6 David  1979
##  7 David  1979
##  8 David  1979
##  9 David  1979
## 10 Allen  1980
## # ℹ 106 more rows

#Tropical wave is the storm with the highest avg_pressure registered

storms_statistics <- storms %>%
  group_by(category, status) %>%
  summarise(avg_pressure = mean(pressure), avg_wind = mean(wind))
## `summarise()` has grouped output by 'category'. You can override using the
## `.groups` argument.
storms_statistics
## # A tibble: 13 × 4
## # Groups:   category [6]
##    category status                 avg_pressure avg_wind
##       <dbl> <fct>                         <dbl>    <dbl>
##  1        1 hurricane                      981.     71.0
##  2        2 hurricane                      967.     89.5
##  3        3 hurricane                      955.    104. 
##  4        4 hurricane                      940.    122. 
##  5        5 hurricane                      918.    146. 
##  6       NA disturbance                   1009.     30.0
##  7       NA extratropical                  993.     41.5
##  8       NA other low                     1009.     25.6
##  9       NA subtropical depression        1008.     26.7
## 10       NA subtropical storm              998.     44.4
## 11       NA tropical depression           1008.     27.5
## 12       NA tropical storm                 999.     45.7
## 13       NA tropical wave                 1009.     28.6

#table containing threecolumns: 1) year of storm, 2) name of storm, and 3) max_wind maximum wind speed record (for that storm).

max_wind_per_storm <- storms %>%
  group_by(name, year) %>%
  summarise(max_wind = max(wind))
## `summarise()` has grouped output by 'name'. You can override using the
## `.groups` argument.
max_wind_per_storm
## # A tibble: 655 × 3
## # Groups:   name [260]
##    name      year max_wind
##    <chr>    <dbl>    <int>
##  1 AL011993  1993       35
##  2 AL012000  2000       25
##  3 AL021992  1992       30
##  4 AL021994  1994       30
##  5 AL021999  1999       30
##  6 AL022000  2000       30
##  7 AL022001  2001       25
##  8 AL022003  2003       30
##  9 AL022006  2006       45
## 10 AL031987  1987       40
## # ℹ 645 more rows

#Dorian, Gilbert and Wilma is the hurricane with highest speed of wind with 160 knotts.

max_wind_per_year <- storms %>%
  group_by(year) %>%
  arrange(desc(wind)) %>%
  slice_head(n = 1) %>%
  select(year, name, wind)

max_wind_per_year
## # A tibble: 48 × 3
## # Groups:   year [48]
##     year name    wind
##    <dbl> <chr>  <int>
##  1  1975 Gladys   120
##  2  1976 Belle    105
##  3  1977 Anita    150
##  4  1978 Ella     120
##  5  1979 David    150
##  6  1980 Allen    165
##  7  1981 Harvey   115
##  8  1982 Debby    115
##  9  1983 Alicia   100
## 10  1984 Diana    115
## # ℹ 38 more rows