Skip to content

Commit

Permalink
calories burned vs intake
Browse files Browse the repository at this point in the history
The “caloriesBurnedVsIntake” argument in get_daily_data only returns
the burned calories. (Maybe fitbit changed something?). I changed the
function to return both caloriesBurned and caloriesIntake. I am not
sure if this is how you want to do it or if you want to split the
dataframe into two seperate dataframes.
  • Loading branch information
stijnmasschelein committed Feb 3, 2016
1 parent 979c21f commit 946eba5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/get_daily_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ get_daily_data <- function(cookie, what="steps", start_date, end_date){
data=as.numeric(unlist(sapply(dat_list$dataPoints, "[", "value"))),
stringsAsFactors=F)
names(df) <- c("time", what)
}else if(what=="caloriesBurnedVsIntake"){
burned_list <- dat_list[[1]]$dataSets$activity$dataPoints
intake_list <- dat_list[[1]]$dataSets$caloriesIntake$dataPoints
df <- data.frame(time=as.character(unlist(sapply(burned_list, "[", "dateTime"))),
caloriesBurned=as.numeric(unlist(sapply(burned_list, "[", 2))),
coloriesIntake=as.numeric(unlist(sapply(intake_list, "[", 2))),
stringsAsFactors=F)
}else{
dat_list <- dat_list[[1]]$dataSets$activity$dataPoints
df <- data.frame(time=as.character(unlist(sapply(dat_list, "[", "dateTime"))),
Expand Down

0 comments on commit 946eba5

Please # to comment.