Upload
tera-monagi
View
3.218
Download
2
Embed Size (px)
Citation preview
俺や
• ID: @teramonagi
•職種:データ分析おじさん
•業務:採用活動&会議&チャット言語:/R/Python/Scala/F#/
•趣味:イケメン&ドラム&メジャーデビュー
3
醜い腹にSay Good-Bye
HealthPlanetというサービスがある
• 株式会社タニタの健康管理サービス
7https://www.healthplanet.jp/
Health Planet APIがある
8https://www.healthplanet.jp/apis/api.html
※三か月分のデータしかとれないというアレ仕様ですが…
healthplanetパッケージ作りました
9https://github.com/teramonagi/healthplanet
インストール&ロード
• Githubからのインストール
13
> install.packages("devtools")> devtools::install_github("teramonagi/healthplanet")> library(healthplanet)
Tokenの取得
• getToken()でトークンを取得
14
> library("healthplanet") > #ブラウザ経由での認証が実行される
> access_token <- getToken()
※healthplanet::getTokenWithoutCheck()もあるが・・・
getInnerScan()を呼ぶだけ
17
> #getInnerScan関数により体重・体脂肪など、タニタの体重計で測定されたデータが取得できる
> df <- getInnerScan(access_token) > df> sex birth_date height date model basal_metabolic_rate body_age body_fat bone_mass muscle_mass muscle_score visceral_fat_level weight 1 male 1963-03-10 180 2016-03-16 06:49:00 01000099 1685 43 20.9 3.1 56.70 0 9.5 75.60 2 male 1963-03-10 180 2016-03-17 08:04:00 01000099 1705 44 21.4 3.1 57.30 0 10 76.85 3 male 1963-03-10 180 2016-03-18 05:48:00 01000099 1677 44 21.2 3.1 56.45 0 9.5 75.55 4 male 1963-03-10 180 2016-03-19 07:11:00 01000099 1667 44 21.2 3.1 56.15 0 9.5 75.15 5 male 1963-03-10 180 2016-03-20 06:39:00 01000099 1687 43 20.5 3.1 56.80 0 9.5 75.35 6 male 1963-03-10 180 2016-03-21 05:28:00 01000099 1675 43 20.7 3.1 56.40 0 9.5 75.00
healthplanet::stakaya()使用例
24
> library("dygraphs") > library("xts") > df <- healthplanet::stakaya() > dygraph(xts(df$body_fat, df$date)) %>% dyRangeSelector()