reate a web page presentation using R Markdown that features a plot created with Plotly. Host your webpage on either GitHub Pages, RPubs, or NeoCities. Your webpage must contain the date that you created the document, and it must contain a plot created with Plotly. We would love to see you show off your creativity!
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
Significant Earthquakes, 1965-2016: This dataset includes a record of the date, time, location, depth, magnitude, and source of every earthquake with a reported magnitude 5.5 or higher since 1965 (https://www.kaggle.com/usgs/earthquake-database)
earthquakes <- read.csv("D:/Coursera/Developing Data Products/Proyecto1/database.csv", header=T)
earthquakes$Date <- as.Date(earthquakes$Date, format= "%m/%d/%Y")
In this exercise we will elaborate different types of diagrams available to build from the Plotly library
Histogram:
histogram <- plot_ly(x = earthquakes$Magnitude, type = "histogram",
marker = list(color = 'green')) %>%
layout(title="Histogram of the events magnitude value", xaxis=list(title="Magnitude"))
histogram
Pie Chart
a <- earthquakes %>%
group_by(Source) %>%
summarise(no_rows = length(Source))
pie <- plot_ly(a, labels = ~Source, values = ~no_rows, type = 'pie')
pie <- pie %>% layout(title = 'Information source of the data',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
pie
Bar Plot
earthquakes.2010to2016 <- subset(earthquakes, Date> "2010-01-01" & Date < "2016-12-31")
earthquakes.2010to2016$YEAR <- format(earthquakes.2010to2016$Date,"%Y")
b <- earthquakes.2010to2016 %>%
group_by(YEAR) %>%
summarise(no_rows = length(Source))
bar <- plot_ly(x=b$YEAR, y=b$no_rows, type = 'bar')%>%
layout(title="Number of evenst by year (2010-2016)", xaxis=list(title="Years"))
bar