Development Data Products Project Submission

Sumeet Singhal
5/25/2020

Functionality of the website

For more details on authoring R presentations please visit https://courserads.shinyapps.io/DevelopingDataProd/

  • Input

    • Input the glucose level either through the textbox or slider to predict your risk level and (Input1)
    • Input the glucose range to find current status ( Input2 )
  • Output

    • Based on Input 1 , we get the input value back from server
    • Get the risk prediction based on Input 1
    • Get the the current status based on Input 2

Code - UI

library(shiny)

Define UI for dataset viewer application

shinyUI( pageWithSidebar( # Application title headerPanel(“Diabetes prediction”),

sidebarPanel(
  numericInput('glucose', 'Glucose mg/dl', 90, min = 50, max = 200, step = 5),
  sliderInput("glucoseSlider","Measure of the glucose level",90,1000, value=90),
  h4("________________________________"),
  h4(""),
  h4("Diabetic/Not Diabetic, select one"),
  checkboxInput("NotDiabetic", "1- 100",value=FALSE ),
  checkboxInput("PreDiabetic", "100- 120",value=FALSE ),
  checkboxInput("Diabetic", "> 120",value=FALSE ),

  submitButton('Submit')
),
mainPanel(
  h3('Results of prediction'),
  h4('You entered'),
  verbatimTextOutput("inputValue"),
  h4('Which resulted in a prediction of '),
  verbatimTextOutput("prediction"),
  h4('What is the result of selection'),
  verbatimTextOutput("inputValue1")
)

) )

code - server

library(shiny)

diabetesRisk <- function(glucose) { x<- “We will find” if(glucose > 120) x <- “Risk is v high” if(glucose < 100) x <- “Risk is low” if(glucose < 120 && glucose > 100) x <- “Risk is high” x }

takehigher <- function(x, y) { if(y > x ) x <- y x }

diabeticeval <- function(diabetic1,diabetic2, diabetic3 ) { x<- “We will find, please select” if(diabetic1) x <- “Not Diabetic” if(diabetic2) x <- “Pre Diabetic” if(diabetic3) x <- “Diabetic” x }

shinyServer( function(input, output) { output$prediction <- renderPrint({diabetesRisk(takehigher(input$glucose, input$glucoseSlider))}) output$inputValue <- renderPrint({takehigher(input$glucose, input$glucoseSlider)}) output$inputValue1 <- renderPrint({diabeticeval(input$NotDiabetic, input$PreDiabetic, input$Diabetic)}) } )

Thanks

Use the website to know about the current status. Also get the risk prediction based on exact reading.

Prediction logic: If glucose level < 100 , then risk level is low If glucose level > 100 , then risk level is V high If glucose level > 100 and < 120 , then risk level is high

Diabetics Prediction logic: If glucose level < 100 , then person is not diabetics If glucose level > 100 , then person is diabetics If glucose level > 100 and < 120 , then person is pre diabetics

** Disclaimer - this data and calculation is for assignment purpose, please visit Doctor for any questions