14/12/2020

Objective for this Assignment

To create a Shiny application and to create a Reproducible pitch using R Presentation:

Dataset used in the Application

Dataset used in the application is Chickweight which is displayed below:

library(MASS)
## Warning: package 'MASS' was built under R version 3.6.3
head(ChickWeight)
##   weight Time Chick Diet
## 1     42    0     1    1
## 2     51    2     1    1
## 3     59    4     1    1
## 4     64    6     1    1
## 5     76    8     1    1
## 6     93   10     1    1

Structure of the dataset

The dataset contains four variables weight, Time, Chick and Diet. The data is recorded for 50 different chicks whose weights were measured from day of birth with Time variable representing no of days since birth. These chicks were kept of 4 types of diet to see impact of diet on their weight and this is represented by the Diet variable.

str(ChickWeight)
## Classes 'nfnGroupedData', 'nfGroupedData', 'groupedData' and 'data.frame':   578 obs. of  4 variables:
##  $ weight: num  42 51 59 64 76 93 106 125 149 171 ...
##  $ Time  : num  0 2 4 6 8 10 12 14 16 18 ...
##  $ Chick : Ord.factor w/ 50 levels "18"<"16"<"15"<..: 15 15 15 15 15 15 15 15 15 15 ...
##  $ Diet  : Factor w/ 4 levels "1","2","3","4": 1 1 1 1 1 1 1 1 1 1 ...
##  - attr(*, "formula")=Class 'formula'  language weight ~ Time | Chick
##   .. ..- attr(*, ".Environment")=<environment: R_EmptyEnv> 
##  - attr(*, "outer")=Class 'formula'  language ~Diet
##   .. ..- attr(*, ".Environment")=<environment: R_EmptyEnv> 
##  - attr(*, "labels")=List of 2
##   ..$ x: chr "Time"
##   ..$ y: chr "Body weight"
##  - attr(*, "units")=List of 2
##   ..$ x: chr "(days)"
##   ..$ y: chr "(gm)"

Shiny Application and working behind the scatter plot

The Shiny Application creates an interactive scatter plot of weight of chick versus age based on type of diet. The type of diet to be considered for plotting cab be chosen by clicking one of the choice buttons for diets 1 to 4 in the application page. The time range for plotting can be chosen using the Slider for time range. The type of point used in plotting the scatter plot can be changed using the Slider for the same. To see relationship between weight versus age, Regression line can be added to the plot by using choice button for the same.

If someone selects Type of Diet as 4, Time Range as 0 to 15, Type of Point to be used in scatter plot as 2 and chooses No for Regression line, then required code will get executed in the Server and a scatter plot will be displayed which is shown in next slide.

Scatter plot