knitr::opts_chunk$set(echo = TRUE)

Task 7

Create a shiny interactive document with a plot of the spruce data.

library(ggplot2)
spruce.df=read.csv("SPRUCE.csv")
inputPanel(selectInput("plotg","Choose plot type",
                       list("Regression Line","Points","Points with Segments")))

renderPlot({

  g=ggplot(spruce.df, aes(x=BHDiameter,y=Height))

  regression=g+geom_smooth(method="lm")

  pointplot=g+geom_point()

  segments=g+geom_point()+geom_line()

  if(input$plotg=="Regression Line") print(regression)
  if(input$plotg=="Points") print(pointplot)
  if(input$plotg=="Points with Segments") print(segments)
})


draket333/MATH4753tayl0062 documentation built on Sept. 10, 2020, 11:49 a.m.