hacking health data
TRANSCRIPT
fitbitscaper for specific functions
#login using Rcookie = login("email", "password", rememberMe = TRUE)
#scrape key datadaily.steps <-get_daily_data(cookie, what="steps", start_date="2011-01-01", end_date=“2016-10-10")
daily.sleep <- get_sleep_data(cookie, start_date="2016-01-01", end_date="2016-10-10")
lubridatetidyverse
hms
http://r4ds.had.co.nz/dates-and-times.html
time challenges R can resolve
<date> formats vary from %Y-%m-%d
<time> units in health & sport sciences
<dttm> date plus time in a single vector
<date> or <dttm> in separate strings
ymd("2017-01-31")
as.integer(10K$time) or period_to_seconds(hms(10K$time))
as.Date("2011-01-31 23:59:59", format = “%Y-%m-%d")
make_datetime(year, month, day, time %/% 100, time %% 100)
finish line fixes
# list the filesfiles <- list.files(path = "data/",pattern = ".csv", full.names = T)# Read the filesl <- lapply(files, read_csv)# combine the dataframesd <- bind_rows(l, .id="year")
dplyr, readr, stringr
full_join(sleep, running, by = "year")