Poject Overview

Create 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
data("presidents")

I am going to use The presidents dataset that contain quarterly approval rating for the President of the United States from Q1-1945 to Q4-1974.

x <- time(presidents)
df <- data.frame(time = x, Approval = presidents)
df$Approval <- as.numeric(df$Approval)
plot_ly(x=df$time, y=df$Approval, type = "bar", color = df$time)
## Warning: Ignoring 6 observations
## Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
## Please use `arrange()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
## Warning: textfont.color doesn't (yet) support data arrays

## Warning: textfont.color doesn't (yet) support data arrays

Next we are going to see tha surface of one volcano

data("volcano")
plot_ly(z= volcano,type = "surface")

We can recreate a box plot for other data set:

data("midwest")
plot_ly(midwest, y = ~ percollege, color = ~state, type = "box")

Finally we can recreate a model fit form other dataset.

library(tidyr)
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
stc <- as.data.frame(EuStockMarkets)%>%
  gather(index, price)%>% mutate(time= rep(time(EuStockMarkets),4), indexes = as.factor(index))

So next we can plot it.

Gr <- stc %>% ggplot(aes(time,price)) + geom_line() + 
  geom_smooth(method = "loess", aes(color= indexes, fill= indexes)) + ggtitle("MOdel Stock Prediction")
  facet_wrap(.~indexes) 
## <ggproto object: Class FacetWrap, Facet, gg>
##     compute_layout: function
##     draw_back: function
##     draw_front: function
##     draw_labels: function
##     draw_panels: function
##     finish_data: function
##     init_scales: function
##     map_data: function
##     params: list
##     setup_data: function
##     setup_params: function
##     shrink: TRUE
##     train_scales: function
##     vars: function
##     super:  <ggproto object: Class FacetWrap, Facet, gg>
ggplotly(Gr)
## `geom_smooth()` using formula 'y ~ x'