Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example interactive app in R
title: "How does your BMI measure up?"
output: flexdashboard::flex_dashboard
runtime: shiny
Inputs {.sidebar}
library(flexdashboard); library(NHANES); library(plotly);library(dplyr)
sliderInput("height", "Height in inches",0,100,72)
sliderInput("weight", "Weight in pounds",0,500,100)
sliderInput("age", "Age in years",0,120,50)
### Chart 1
nhanes = sample_n(NHANES,100)
df = data.frame(bmi = c(nhanes$BMI,input$weight*0.45/(input$height*0.025)^2),
age = c(nhanes$Age,input$age),
who = c(rep("nhanes",100),"you"))
ggplotly(ggplot(df) +
geom_point(aes(x=age,y=bmi,color=who)) +
scale_x_continuous(limits=c(0,90)) +
scale_y_continuous(limits=c(0,60)) +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment