September 21, 2020

The Assignment

The goal of this assignment is to build:

A Shiny application that has widget input, ui input in server.R, reactive output using server calculations, and supporting documentation.

A Reproducible Pitch Presentation that contains five slides in either Slidify or Rstudio Presenter that is pushed to and hosted on GitHub or Rpubs and contains embedded R code that runs.

What is This App Doing ?

The application takes a predictor as an input and fits a univariate linear regression for output variable mpg. You can give various predictor inputs to predict mpg values with your input. Plot is done with plotly package, so it is interactive plot.

Code for Linear Model

Here is an example for one of the linear models.

fit <- lm(mpg ~ hp, data = mtcars)
summary(fit)
Call:
lm(formula = mpg ~ hp, data = mtcars)

Residuals:
    Min      1Q  Median      3Q     Max 
-5.7121 -2.1122 -0.8854  1.5819  8.2360 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 30.09886    1.63392  18.421  < 2e-16 ***
hp          -0.06823    0.01012  -6.742 1.79e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.863 on 30 degrees of freedom
Multiple R-squared:  0.6024,    Adjusted R-squared:  0.5892 
F-statistic: 45.46 on 1 and 30 DF,  p-value: 1.788e-07

Plot for Linear Model

Here is an example of interactive plot that you can create with your input.

library(ggplot2)
library(plotly)
g <- ggplot(mtcars, aes(x = hp, y = mpg)) +
  geom_point(size = 2) +
  geom_smooth(method = "lm", formula = y ~ x)
fig <- ggplotly(g)

Plot for Linear Model (ctd.)

Thank You !

Thank you for viewing my basic app and reading till this slide.

Have a good day !