Winnie M.
2020/12/16
The purpose of the App is to predict bodyfat ratio with one's weight and height using the 'bodyfat' data set.
Create the data input and output User Interface (UI) in ui.R
Create the data computing function in server.R
# Read the dataset and remove outlier
bodyfat <- read.csv("http://staff.pubhealth.ku.dk/~tag/Teaching/share/data/Bodyfat.csv")
bodyfat <- bodyfat[,-1]; bodyfat <- bodyfat[-42,]
## Change the unit of inputs and compute BMI
bodyfat$BMI <- bodyfat$Weight*0.4536 / (bodyfat$Height*0.0254)^2
dim(bodyfat)
[1] 251 15
head(bodyfat[,c(3:4,15)])
Weight Height BMI
1 154.25 67.75 23.62720
2 173.25 72.25 23.33475
3 154.00 66.25 24.66917
4 184.75 72.25 24.88367
5 184.25 71.25 25.51781
6 210.25 74.75 26.45570
# Fit the linear model
fit.lm <- lm(bodyfat~BMI, data=bodyfat)
fit.lm$coef
(Intercept) BMI
-22.859366 1.652687