author: Rafael Del Grande date:
r format(Sys.Date(), '%B %d, %Y') autosize: true
Many people don’t know their BMI or daily caloric needs — two key indicators of metabolic health.
A simple, interactive BMI & Health Risk Calculator that:
Anyone interested in tracking their health metrics — no medical knowledge required!
The app uses the Mifflin-St Jeor equation for caloric needs:
```{r formula_demo} calculate_bmr <- function(weight_kg, height_cm, age, gender) { if (gender == “male”) { bmr <- (10 * weight_kg) + (6.25 * height_cm) - (5 * age) + 5 } else { bmr <- (10 * weight_kg) + (6.25 * height_cm) - (5 * age) - 161 } return(round(bmr)) }
bmr <- calculate_bmr(70, 175, 30, “male”) cat(“Base Metabolic Rate:”, bmr, “kcal/day”) cat(“With moderate activity (x1.55):”, round(bmr * 1.55), “kcal/day”)
BMI Distribution
========================================================
```{r bmi_chart, fig.width=10, fig.height=5, echo=FALSE}
library(ggplot2)
set.seed(42)
bmi_data <- data.frame(
BMI = c(rnorm(200, 17, 1),
rnorm(800, 22, 2),
rnorm(600, 27, 1.5),
rnorm(300, 33, 2),
rnorm(100, 42, 2))
)
ggplot(bmi_data, aes(x = BMI)) +
geom_histogram(aes(fill = cut(BMI,
breaks = c(0, 18.5, 25, 30, 35, 100),
labels = c("Underweight","Normal","Overweight","Obese I","Obese II+"))),
bins = 40, alpha = 0.85, color = "white") +
scale_fill_manual(
values = c("#3498db","#2ecc71","#f39c12","#e67e22","#e74c3c"),
name = "Category") +
geom_vline(xintercept = c(18.5, 25, 30, 35),
linetype = "dashed", color = "grey40") +
labs(title = "BMI Category Distribution", x = "BMI", y = "Count") +
theme_minimal(base_size = 14)
Input Widgets
| Widget | Input |
|---|---|
| Slider | Age (10-100 years) |
| Radio Buttons | Gender & Unit System |
| Numeric Input | Height & Weight |
| Dropdown | Activity Level (5 options) |
| Checkbox | Smoking Status |
| Action Button | Trigger calculation |
Reactive Outputs - BMI value with color-coded category - Daily calorie estimate - Health risk score (0-100) - Personalized recommendations
Live App
https://rdelgrande.shinyapps.io/developing_data_products_final_proj/
ui.R - All input widgets and layoutserver.R - BMI, calorie & risk calculations{r packages, eval=FALSE} library(shiny) # Web app framework library(ggplot2) # Visualization
For educational purposes only. Always consult a healthcare professional for medical advice.
Created: r format(Sys.Date(), '%B %d, %Y')