I have the following code to create a table in R
. How can I add unit to Height
and Weight
and BMI
? (so it would be like Height (in)
and Weight (lb)
and BMI (kg/m2)
)
Height <- c(66, 73, 65, 68, 71)
Weight <- c(121,191,177,159,152)
#pound to kilogram and inche to meter
#BMI=kg/m^2
BMI = Weight * 0.45/(Height * 0.02)^2
expn <- data.frame (Height, Weight, BMI)
knitr::kable (expn, caption = "Body Measurments", align = c ("c", "c"))
If all you want to do is add the units to the column names you could use
colnames
andpaste0
.Table: Body Measurements