mydata <- data.frame("ID" = c(1, 2, 3, 4, 5),
"Height" = c(170, 172, 174, 176, 180),
"Weight" = c(60, 62, 64, 66, 70))
mean(mydata$Height)
## [1] 174.4
On average everyone in the sample has 174.4 cm.
summary(mydata[ ,-1])
## Height Weight
## Min. :170.0 Min. :60.0
## 1st Qu.:172.0 1st Qu.:62.0
## Median :174.0 Median :64.0
## Mean :174.4 Mean :64.4
## 3rd Qu.:176.0 3rd Qu.:66.0
## Max. :180.0 Max. :70.0
mydata$Gender <- c("F", "M", "F", "F", "M")
mydata$BMI <- round(mydata$Weight/(mydata$Height/100)^2,1)