April 1, 2018

Heath Indicator using Body Mass Index (BMI)

Body Mass Index (BMI) is a simple health indicator using the height and weight of a person. The formula is BMI = a person's weight (kg) divided by the square of his height (m).

This simple app calculates your BMI and the amount of weight to gain (if you are underweight) or to lose (if you are overweight or obese).

Note that BMI is not appropriate for use as a health indicator for pregnant women, the elderly, young children and muscle-builders.

App Features

  • Computes your BMI
  • Tells you whether you have a normal body weight
  • Computes your ideal weight based on your height
  • Computes the amount of weight to gain or lose to reach normal body weight (ideal weight) range
  • Shows where your weight is vis-a-vis the ideal weight

R Code for the User Interface at ui.R

library(shiny)
## Warning: package 'shiny' was built under R version 3.4.4
shinyUI(fluidPage(
sidebarPanel(
sliderInput('wt','Enter Your Weight (kg)',value=50,min= 20, max=200, step=0.05),
sliderInput('ht','Enter Your Height (cm)',value=150,min= 40, max=300, step=0.05),
submitButton("Submit")),
mainPanel(
  h2('Documentation on the Use of this App'), ## Details not displayed
  h2('Your BMI'), verbatimTextOutput("bmi"), verbatimTextOutput("text"),
  h2('Your Ideal Weight based on Your Height'),
  h5('Minimum (kg)'), verbatimTextOutput('idealmin'),
  h5('Maximum (kg)'), verbatimTextOutput('idealmax'),
  plotOutput("plot1"))))

Output: Comparison Chart

Pseudo Inputs: Weight = 40kg, Height = 160cm

[1] "Your BMI is 15.62.You are underweight."
[1] "Please gain 7.36 to 23.74 kg to reach a normal body weight."