Instructions

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!

Review criteria

1.- Does the web page feature a date and is this date less than two months before the date that you’re grading this assignment? 2.- Is the web page a presentation and does it feature an interactive plot that appears to have been created with Plotly?

Date, libraries data used

library(magrittr)
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

Today is:

Sys.Date()
## [1] "2020-10-13"

The dataset used will be: mtcars

A small summary:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Plotly

I’ll show a basic linear regression model on the mtcars plot. First we get the lm

fit <- lm(mpg ~ wt + cyl, data = mtcars)

Next we draw each linear model with the color of the cyl used.

mtcars %>% 
  plot_ly(x = ~wt, mode="markers", color = as.factor(mtcars$cyl)) %>%
  add_markers(y = ~mpg) %>%
  add_lines(x = ~wt, y = fitted(fit))