R functions for body composition trends