git clone https://github.com/kizen777/Health_Manage.git
cd Health_Manage
# 必要なパッケージ
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 |
レポート生成 |
公式ドキュメント: TANITA Health Planet API 仕様書 Ver1.0.1
BMI基準値: WHO国際基準に基づく 体脂肪率: 年齢・性別別基準値を使用
トレンド分析: 7日・30日移動平均による平滑化
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
Plot Interpretation The weight plot includes reference lines based on international health guidelines for adults:
These visualizations provide valuable insights into body composition changes, supporting effective health monitoring and informed goal setting.