BMI-calculation app

Gerard van Meurs
April 10, 2019

Introduction

To test the BMI-app, please go to: https://gerardvanmeurs.shinyapps.io/BMI-Calculator.

With this Shiny-app you can calculate your Body Mass Index (BMI) based on:

  • your weight in kg
  • your height in cm

The app:

  • will display your BMI-value
  • will display the WHO-suggested classification
  • contains a documentation tab

Design

  • a separate ui.R and a server.R
  • pageWithSidebar instead of a FluidPage design
  • layout in ui.R
  • computation in server.R
  • non-reactive computation by means of SubmitButton

server.R

Real 'work' is done in the server.R part:

library(shiny) 
bmi <- function(weight,height) {round(weight/((height/100)^2),1)}
bmiCat <- function(bmi){
  ifelse(bmi < 18.5,"underweight",ifelse(bmi < 25,"normal weight",ifelse(bmi < 30,"overweight","obese")))
}
shinyServer(
  function(input, output) {
    output$inputweightvalue <- renderPrint({input$weight})
    output$inputheightvalue <- renderPrint({input$height})
    output$output <- renderPrint({bmi(input$weight,input$height)})
    output$calculate <- renderPrint({bmiCat(bmi(input$weight,input$height))})
  } 
)

QandA

  • any questions?
  • Thank you for your time and attention!!