Skip to content

Latest commit

 

History

History
80 lines (56 loc) · 1.92 KB

index.md

File metadata and controls

80 lines (56 loc) · 1.92 KB
title subtitle author job framework highlighter hitheme widgets mode knit
Slidyfy My Shiny
App BMI caculator
Yihui Zuo
Graduate Student in North China Electric Power University
minimal
highlight.js
tomorrow
selfcontained
slidify::knit2slides

Introduce the The BMI Calculator

This presentaion will show the code of my application-- the Body Mass Index (BMI) calculator.

The App can be found at shinyapps


Creat the User-interface definition

library(shiny)
### Define UI for application that calculates your Body Mass Index(BMI) 
shinyUI(
  pageWithSidebar(
    # Application title
    headerPanel("BMI Caculator"),
   
  # Sidebar with the height and weight text input
    sidebarPanel(
      
      numericInput('height', 'Height m', 1.65, min = 0, max = 3, step = 0.01),
      numericInput('weight', 'Weight kg', 50, min = 0, max = 300, step = 0.5),
      submitButton('Submit')
    ),
      
    # Show the result of BMI
    mainPanel(
      h3('Your BMI'),
      verbatimTextOutput("result"),
      h3('BMI reference value'),
      h4('<18.5 | Underweight'),
      h4('18.5~24.9 |   Normal'),
      h4('>=25.0  |  Overweight')

     
    )
  )
)

This is the server logic of the Shiny

library(shiny)

#caculate the BMI 
#Calculate function
BMI <- function(height,weight) weight/(height)^2

# Print the result
shinyServer(function(input, output) {
   
  output$result <- renderPrint({BMI(input$height,input$weight)})
    
   
}

Information

Find out more about building applications with Shiny hereMy github