Body Measurements

Estimating percentage of body fat is one method by which the health of a person is assessed. To measure it accurately is often inconvenient or costly (finding density involves underwater weighing), so methods of estimation have been derived using more conveniently obtained measurements. The densities of 252 men were measured, and from that, their percent body fat was determined. Many other body measurements were also taken for comparison and estimation.
MATH221
health
Author

MATH 221

Published

April 22, 2024

Data details

There are 252 rows and 15 columns. The data source1 is used to create our data that is stored in our pins table. You can access this pin from a connection to posit.byui.edu using hathawayj/body_measurements.

This data is available to all.

Variable description

  • Density: Density determined from underwater weighing (g/cm3)
  • BodyFat: Percent body fat from Siri’s (1956) equation
  • Age: Age (years)
  • Weight: Weight (lbs)
  • Height: Height (inches)
  • Neck: Neck circumference (cm)
  • Chest: Chest circumference (cm)
  • Abdomen: Abdomen circumference (cm)
  • Hip: Hip circumference (cm)
  • Thigh: Thigh circumference (cm)
  • Knee: Knee circumference (cm)
  • Ankle: Ankle circumference (cm)
  • Bicep: Biceps (extended) circumference (cm)
  • Forearm: Forearm circumference (cm)
  • Wrist: Wrist circumference (cm)

Variable summary

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Density 0 1 1.06 0.02 1.0 1.04 1.05 1.07 1.11 ▁▅▇▆▁
BodyFat 0 1 19.15 8.37 0.0 12.47 19.20 25.30 47.50 ▃▇▇▃▁
Age 0 1 44.88 12.60 22.0 35.75 43.00 54.00 81.00 ▅▇▇▃▁
Weight 0 1 178.92 29.39 118.5 159.00 176.50 197.00 363.15 ▆▇▂▁▁
Height 0 1 70.31 2.61 64.0 68.25 70.00 72.25 77.75 ▂▇▇▅▁
Neck 0 1 37.99 2.43 31.1 36.40 38.00 39.42 51.20 ▂▇▃▁▁
Chest 0 1 100.82 8.43 79.3 94.35 99.65 105.38 136.20 ▂▇▅▁▁
Abdomen 0 1 92.56 10.78 69.4 84.57 90.95 99.33 148.10 ▃▇▂▁▁
Hip 0 1 99.90 7.16 85.0 95.50 99.30 103.53 147.70 ▆▇▁▁▁
Thigh 0 1 59.46 5.26 47.0 56.00 59.00 62.25 87.00 ▃▇▂▁▁
Knee 0 1 38.59 2.41 33.0 36.98 38.50 39.92 49.10 ▃▇▅▁▁
Ankle 0 1 23.10 1.69 19.1 22.00 22.80 24.00 33.90 ▃▇▁▁▁
Bicep 0 1 32.34 3.01 25.0 30.00 32.00 34.00 45.00 ▃▇▅▁▁
Forearm 0 1 28.66 2.02 21.0 27.30 28.70 30.00 34.90 ▁▂▇▆▁
Wrist 0 1 18.23 0.93 15.8 17.60 18.30 18.80 21.40 ▂▆▇▂▁
NULL
Explore generating code using R
library(tidyverse)
library(pins)
library(connectapi)

body_measurements <- read_csv('https://github.com/byuistats/data/raw/master/BodyMeasurementsCorrected/BodyMeasurementsCorrected.csv')


# Publish the data to the server with Bro. Hathaway as the owner.
board <- board_connect()
pin_write(board, body_measurements, type = "parquet", access_type = "all")

pin_name <- "body_measurements"
meta <- pin_meta(board, paste0("hathawayj/", pin_name))
client <- connect()
my_app <- content_item(client, meta$local$content_id)
set_vanity_url(my_app, paste0("data/", pin_name))

Access data

This data is available to all.

Direct Download: body_measurements.parquet

R and Python Download:

URL Connections:

For public data, any user can connect and read the data using pins::board_connect_url() in R.

library(pins)
url_data <- "https://posit.byui.edu/data/body_measurements/"
board_url <- board_connect_url(c("dat" = url_data))
dat <- pin_read(board_url, "dat")

Use this custom function in Python to have the data in a Pandas DataFrame.

import pandas as pd
import requests
from io import BytesIO

def read_url_pin(name):
  url = "https://posit.byui.edu/data/" + name + "/" + name + ".parquet"
  response = requests.get(url)
  if response.status_code == 200:
    parquet_content = BytesIO(response.content)
    pandas_dataframe = pd.read_parquet(parquet_content)
    return pandas_dataframe
  else:
    print(f"Failed to retrieve data. Status code: {response.status_code}")
    return None

# Example usage:
pandas_df = read_url_pin("body_measurements")

Authenticated Connection:

Our connect server is https://posit.byui.edu which you assign to your CONNECT_SERVER environment variable. You must create an API key and store it in your environment under CONNECT_API_KEY.

Read more about environment variables and the pins package to understand how these environment variables are stored and accessed in R and Python with pins.

library(pins)
board <- board_connect(auth = "auto")
dat <- pin_read(board, "hathawayj/body_measurements")
import os
from pins import board_rsconnect
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv('CONNECT_API_KEY')
SERVER = os.getenv('CONNECT_SERVER')

board = board_rsconnect(server_url=SERVER, api_key=API_KEY)
dat = board.pin_read("hathawayj/body_measurements")