Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

https://1drv.ms/x/s!An8sv1t-dz8vhxdWP-th3TpRzXwN <- csv file Using R programming

ID: 3073520 • Letter: H

Question

https://1drv.ms/x/s!An8sv1t-dz8vhxdWP-th3TpRzXwN <- csv file

Using R programming language

1. For the following questions, use the file "Earthquakes.csv". There is a header in the data. This dataset consists of information about Worldwide Earthquakes of Magnitudes 6-6.9, 7- 7.9, and 8 for the years 2000-2007. This information came from usgs.gov. a) How many earthquakes are there per year? b) How many earthquakes are there per magnitude category? (c) For each magnitude category, find the average year that the earthquakes occurred. (d) Make a histogram displaying the frequency of earthquakes per year. Have the break points be the years 2000,2001,..,2008. Make the histogram such that the cells are right-open (left closed) intervals. (e) Does it appear that any year had more earthquakes than the other years, i.e. are any years outliers and why? If necessary, provide an appropriate chart

Explanation / Answer

R code is:

Earthquakes <- read_excel("C:/Users/M1045151/Downloads/Earthquakes.xlsx")
View(Earthquakes)
dim(Earthquakes)
names(Earthquakes)
Earthquakes_n <- Earthquakes %>% count(Year, sort = TRUE)
print(Earthquakes_n)

ANSWER:

Year n

1 2007 197
2 2000 161
3 2004 157
4 2003 155
5 2006 153
6 2005 151
7 2002 140
8 2001 137

Solutionb:

Earthquakes_magnitude <- Earthquakes %>% count(Magnitude, sort = TRUE)
print(Earthquakes_magnitude)

ANSWER:

Magnitude n
  
1 6-6.9 1135
2 7-7.9 103
3 8 13

Solutionc:

library(dplyr)

Earthquakes %>%
group_by(Magnitude) %>%
summarize(mean_year = mean(Year, na.rm = TRUE))

ANSWER:

Magnitude mean_year
<chr> <dbl>
1 6-6.9 2004.
2 7-7.9 2003.
3 8 2005.