Learn R Programming

PASWR2 (version 1.0.5)

BODYFAT: Body Fat Composition

Description

Values from a study reported in the American Journal of Clinical Nutrition that investigated a new method for measuring body composition

Usage

BODYFAT

Arguments

Format

A data frame with 18 observations on the following 3 variables:

  • age (age in years)

  • fat (percent body fat composition)

  • sex (a factor with levels F for female and M for male)

References

Ugarte, M. D., Militino, A. F., and Arnholt, A. T. 2015. Probability and Statistics with R, Second Edition. Chapman & Hall / CRC.

Examples

Run this code
# NOT RUN {
# base graphics
boxplot(fat ~ sex, data = BODYFAT)
# ggplot2 approach
ggplot(data=BODYFAT, aes(x = sex, y = fat, fill = sex)) + geom_boxplot() + 
labs(x = "",y = "Percent body fat") + scale_x_discrete(breaks=c("F", "M"), 
labels =c("Female", "Male")) + guides(fill = "none") + 
scale_fill_manual(values = c("red", "green"))
# Brewer Colors
ggplot(data=BODYFAT, aes(x = sex, y = fat, fill = sex)) + geom_boxplot() + 
labs(x = "", y = "Percent body fat") + scale_x_discrete(breaks=c("F", "M"), 
labels =c("Female", "Male")) + guides(fill = "none") + scale_fill_brewer()
ggplot(data=BODYFAT, aes(x = fat, fill = sex)) + geom_density(alpha = 0.4) + 
scale_fill_brewer() 
# }

Run the code above in your browser using DataLab