2024-05-09

Overview

  • The goal of this assignment is to create a web page presentation using R markdown ioSlides and plotly.
  • We generated multi-line graph using the built-in “ChickWeight” dataset
  • The plot shows the body weight progress on chicks fed on four experimental diets over 21 days.

Interactive plot generated by plotly

Appendix: R code

##Load Required Pacakges and dataset
library(plotly)
library(dplyr)
data("ChickWeight")
##Group chicks by diet type and calculate their mean weights on each day.
chicks <- ChickWeight %>%
        group_by(Diet, Time) %>%
        summarize(mean_wt = mean(weight))
##Create Plot
plot_ly(chicks, x=~Time, y=~mean_wt, color = ~Diet, type="scatter", 
        mode="lines", 
        name=paste("diet", chicks$Diet, sep=" ")) %>%
        layout(
                title = "Chick Weights by Diets",
                xaxis = list(title = 'Days since Birth'),
                yaxis = list(title = 'Mean Chick Weight (gram)'),
                showlegend=TRUE
                )