This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
tornados <- read.csv('C:/Users/vj/downloads/tornados.csv')
#summary of the tornados table
summary(tornados)
## om yr mo dy
## Min. : 1 Min. :1950 Min. : 1.000 Min. : 1.00
## 1st Qu.: 285 1st Qu.:1976 1st Qu.: 4.000 1st Qu.: 8.00
## Median : 588 Median :1995 Median : 6.000 Median :16.00
## Mean :113202 Mean :1992 Mean : 5.969 Mean :15.93
## 3rd Qu.: 1118 3rd Qu.:2008 3rd Qu.: 7.000 3rd Qu.:24.00
## Max. :622080 Max. :2022 Max. :12.000 Max. :31.00
##
## date time tz datetime_utc
## Length:68693 Length:68693 Length:68693 Length:68693
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## st stf mag inj
## Length:68693 Min. : 1.00 Min. :0.0000 Min. : 0.000
## Class :character 1st Qu.:18.00 1st Qu.:0.0000 1st Qu.: 0.000
## Mode :character Median :28.00 Median :1.0000 Median : 0.000
## Mean :29.22 Mean :0.7787 Mean : 1.419
## 3rd Qu.:42.00 3rd Qu.:1.0000 3rd Qu.: 0.000
## Max. :78.00 Max. :5.0000 Max. :1740.000
## NA's :756
## fat loss slat slon
## Min. : 0.00000 Min. :5.000e+01 Min. :17.72 Min. :-163.53
## 1st Qu.: 0.00000 1st Qu.:1.000e+04 1st Qu.:33.18 1st Qu.: -98.42
## Median : 0.00000 Median :5.000e+04 Median :37.00 Median : -93.56
## Mean : 0.08931 Mean :2.021e+06 Mean :37.13 Mean : -92.76
## 3rd Qu.: 0.00000 3rd Qu.:5.000e+05 3rd Qu.:40.92 3rd Qu.: -86.73
## Max. :158.00000 Max. :2.800e+09 Max. :61.02 Max. : -64.72
## NA's :27170
## elat elon len wid
## Min. : 0.00 Min. :-163.53 Min. : 0.000 Min. : 0.0
## 1st Qu.: 0.00 1st Qu.: -94.78 1st Qu.: 0.120 1st Qu.: 20.0
## Median :32.55 Median : -84.72 Median : 0.800 Median : 50.0
## Mean :22.96 Mean : -56.84 Mean : 3.489 Mean : 107.8
## 3rd Qu.:38.65 3rd Qu.: 0.00 3rd Qu.: 3.210 3rd Qu.: 100.0
## Max. :61.02 Max. : 0.00 Max. :234.700 Max. :4576.0
##
## ns sn f1 f2
## Min. :1.000 Min. :0.0000 Min. : 0.0 Min. : 0.000
## 1st Qu.:1.000 1st Qu.:1.0000 1st Qu.: 37.0 1st Qu.: 0.000
## Median :1.000 Median :1.0000 Median : 85.0 Median : 0.000
## Mean :1.009 Mean :0.9914 Mean :104.6 Mean : 8.605
## 3rd Qu.:1.000 3rd Qu.:1.0000 3rd Qu.:137.0 3rd Qu.: 0.000
## Max. :3.000 Max. :1.0000 Max. :810.0 Max. :820.000
##
## f3 f4 fc
## Min. : 0.000 Min. : 0.0000 Mode :logical
## 1st Qu.: 0.000 1st Qu.: 0.0000 FALSE:66830
## Median : 0.000 Median : 0.0000 TRUE :1863
## Mean : 1.687 Mean : 0.5068
## 3rd Qu.: 0.000 3rd Qu.: 0.0000
## Max. :710.000 Max. :507.0000
##
#data documentation
om integer Tornado number. Effectively an ID for this tornado in this year. yr integer Year, 1950-2022. mo integer Month, 1-12. dy integer Day of the month, 1-31. date date Date. time time Time. tz character Canonical tz database timezone. datetime_utc datetime Date and time normalized to UTC. st character Two-letter postal abbreviation for the state (DC = Washington, DC; PR = Puerto Rico; VI = Virgin Islands). stf integer State FIPS (Federal Information Processing Standards) number. mag integer Magnitude on the F scale (EF beginning in 2007). Some of these values are estimated (see fc). inj integer Number of injuries. When summing for state totals, use sn == 1 (see below). fat integer Number of fatalities. When summing for state totals, use sn == 1 (see below). loss double Estimated property loss information in dollars. Prior to 1996, values were grouped into ranges. The reported number for such years is the maximum of its range. slat double Starting latitude in decimal degrees. slon double Starting longitude in decimal degrees. elat double Ending latitude in decimal degrees. elon double Ending longitude in decimal degrees. len double Length in miles. wid double Width in yards. ns integer Number of states affected by this tornado. 1, 2, or 3. sn integer State number for this row. 1 means the row contains the entire track information for this state, 0 means there is at least one more entry for this state for this tornado (om + yr). f1 integer FIPS code for the 1st county. f2 integer FIPS code for the 2nd county. f3 integer FIPS code for the 3rd county. f4 integer FIPS code for the 4th county. fc logical Was the mag column estimated?
#goal/purpose Tornados data occured from the year 1950-2022 ,to study and research various elements from the data.
#deriving standard deviation
standard_deviation <- sd(tornados$mo, na.rm= TRUE)
#deriving variation
variation <- var(tornados$mag, na.rm= TRUE)
#sum of magnitude of tornados
summ <- sum(tornados$inj)
standard_deviation
## [1] 2.444656
variation
## [1] 0.8024394
summ
## [1] 97454
library(ggplot2)
ggplot(tornados,(aes(len,wid))) + geom_point(size=2,color="green")
ggplot(tornados, aes(x = len)) +
geom_histogram(binwidth = 10, fill = "red", color = "black") +
labs(title = "histogram example", x = "len", y = "stf")
boxplot(tornados$stf, main="Box Plot of stf")
pie(table(tornados$mag), main="Pie Chart of magnitude")
result <- aggregate(tornados$mag,by=list(tornados$yr), mean)
result
## Group.1 x
## 1 1950 1.6019900
## 2 1951 1.3653846
## 3 1952 1.6916667
## 4 1953 1.5201900
## 5 1954 1.3618182
## 6 1955 1.1455161
## 7 1956 1.2743539
## 8 1957 1.2905484
## 9 1958 1.1560284
## 10 1959 1.1672185
## 11 1960 1.2548701
## 12 1961 1.3271162
## 13 1962 1.0837139
## 14 1963 1.2829374
## 15 1964 1.2315341
## 16 1965 1.2664437
## 17 1966 1.0854701
## 18 1967 1.1382289
## 19 1968 1.1354642
## 20 1969 1.1036184
## 21 1970 1.1944870
## 22 1971 1.2553431
## 23 1972 1.1256757
## 24 1973 1.2422868
## 25 1974 1.3093220
## 26 1975 0.9836779
## 27 1976 1.0887290
## 28 1977 1.0387324
## 29 1978 0.7984791
## 30 1979 0.8128655
## 31 1980 0.9710983
## 32 1981 0.9143223
## 33 1982 0.9541109
## 34 1983 0.9172043
## 35 1984 0.8697572
## 36 1985 0.7909357
## 37 1986 0.7555556
## 38 1987 0.6265244
## 39 1988 0.7934473
## 40 1989 0.7500000
## 41 1990 0.7775816
## 42 1991 0.5715548
## 43 1992 0.6607556
## 44 1993 0.5093857
## 45 1994 0.5027726
## 46 1995 0.4761520
## 47 1996 0.4893436
## 48 1997 0.5043554
## 49 1998 0.5287921
## 50 1999 0.5772965
## 51 2000 0.4306977
## 52 2001 0.4666667
## 53 2002 0.4743041
## 54 2003 0.4759825
## 55 2004 0.4210237
## 56 2005 0.4552652
## 57 2006 0.5222121
## 58 2007 0.5324201
## 59 2008 0.5837774
## 60 2009 0.5043253
## 61 2010 0.5768931
## 62 2011 0.7616795
## 63 2012 0.5511727
## 64 2013 0.6070640
## 65 2014 0.6106095
## 66 2015 0.5012744
## 67 2016 NA
## 68 2017 NA
## 69 2018 NA
## 70 2019 NA
## 71 2020 NA
## 72 2021 NA
## 73 2022 NA
barplot(result$x, names.arg=result$Group.1, xlab="yr", ylab="mag", col=rainbow(6),
main="magnitude vs year",border="black")