Health_Manage(作成中)

Weight Plot Body Fat & BMI Plot

📊 TANITA Health Planet APIを活用した体組成データ管理・解析ツール

✨ 特徴

  • 🔄 自動データ取得: TANITA Health Planet APIから体重・体脂肪率データを自動取得
  • 📅 柔軟な期間指定: 任意の日付範囲でのデータ取得が可能
  • 📈 美しい可視化: ggplot2による高品質なグラフとトレンド分析
  • 🔍 包括的な解析: BMI計算、健康指標との比較、統計的分析
  • 📝 レポート生成: Quartoによる自動レポート作成

🚀 クイックスタート

必要な環境

  • R 4.0以上
  • RStudio(推奨)
  • TANITA Health Planet アカウント

インストール

  1. リポジトリをクローン
git clone https://github.com/kizen777/Health_Manage.git
cd Health_Manage

2. 必要なRパッケージをインストー

# 必要なパッケージ
packages <- c(
  "httr",           # HTTP通信ライブラリ
  "jsonlite",       # JSON処理ライブラリ
  "lubridate",      # 日付処理ライブラリ
  "dplyr",          # データ操作ライブラリ
  "ggplot2",        # グラフ作成ライブラリ
  "quarto")         # レポート生成ライブラリ

install.packages(packages)

セットアップ

1. API認証情報の設定 API/credentials.R に認証情報を保存

client_id <- "your_client_id"
client_secret <- "your_client_secret"
redirect_uri <- "your_redirect_uri"

2. 認可コードの取得 - TANITA認証ページ から認可コードを取得

  • ⚠️ 重要:認可コード: 有効期限5分、都度取得が必要

  • 認証情報: credentials.Rは絶対にGitにコミットしないでください

3. データ取得と解析

source(“main.R”)

📊 使用例

# データ取得
health_data <- get_tanita_data(
  start_date = "2024-01-01",
  end_date = "2024-12-31"
)

可視化

plot_weight_trends(health_data)

plot_body_fat_analysis(health_data)

plot_bmi_tracking(health_data)

レポート生成

generate_health_report(health_data)

📁 プロジェクト構造

Health_Manage/
├── README.md
├── main.R                   # メインスクリプト
├── API/                     # 個人情報につき, id 等はclent_id に必要情報を記載し,コードには直接記載しない
│     └─ client_id           # このファイルに下記含むます
│        └── client_secret   # 
│        └── redirect_url    #
│        └── code            #
├── scripts/
│   ├── data_processing.R    # データ処理
│   └── visualization.R      # 可視化関数
├── reports/
│   └── health_report.qmd    # Quartoレポートテンプレート
└── data/
└── output/                  # 取得データの保存先
client_id     = client_id,
client_secret = client_secret,
redirect_uri  = redirect_uri,
code          = auth_code,

📋 必要なパッケージ

パッケージ 用途
httr API通信
jsonlite JSON処理
lubridate 日付処理
dplyr データ操作
ggplot2 グラフ作成
quarto レポート生成

健康指標について(未)

BMI基準値: WHO国際基準に基づく 体脂肪率: 年齢・性別別基準値を使用

トレンド分析: 7日・30日移動平均による平滑化

⚠️ 注意事項

  • 認可コード: 有効期限5分、都度取得が必要
  • 認証情報: credentials.Rは絶対にGitにコミットしないでください
  • データプライバシー: 個人の健康データを扱うため、適切な管理を心がけてください
  • API制限: Health Planet APIの利用規約を遵守してください

🤝 コントリビューション

  1. このリポジトリをフォーク
  2. フィーチャーブランチを作成 (git checkout -b feature/amazing-feature)
  3. 変更をコミット (git commit -m ‘Add amazing feature’)
  4. ブランチをプッシュ (git push origin feature/amazing-feature) プルリクエストを作成

📄 このプロジェクトは MIT License の下で公開されています。

👨‍💻 作者

Kizen Sasaki - GitHub: @kizen777

  • 個人の健康管理とデータ解析に情熱を注いでいます。

Overview

This Quarto document analyzes and visualizes body composition data for a male subject, focusing on weight, BMI, and body fat percentage trends over time. The data is collected from the Tanita API and processed using R.

Data Processing and Visualization

The analysis utilizes dplyr and tidyr for data manipulation, and ggplot2 for creating clear, informative plots that highlight trends in body composition metrics. The visualizations are designed to support personal health tracking and goal setting.

Technical Requirements

  • Ensure all necessary R packages (dplyr, tidyr, ggplot2) are installed and loaded
  • The code assumes a fixed height of 172 cm for BMI calculations—modify this value for different individuals
  • Adjust the height variable as needed for accurate BMI calculations

Plot Interpretation The weight plot includes reference lines based on international health guidelines for adults:

  • Red dotted line: Maximum healthy weight limit for men
  • Green dotted line: Minimum healthy weight boundary

These visualizations provide valuable insights into body composition changes, supporting effective health monitoring and informed goal setting.