Description Usage Format Fields Methods Examples
Person
is an object that encapsulates an individual's
data over a specified date range (start and end date stored as Date
objects.
An individual consists of basic information, such as name, age,
and gender (a list
with named elements), data from their self-tracking
devices such as Fitbit, Apple health, etc. (data from each source is a tibble
dataframe), individual goals such as target steps (numeric
),
additional data from self-tracking apps or one's own collection system
(stored as a tibble dataframe), and ways of grouping the data a user may be
interested in, such as grouping by seasons, or comparing weekend to weekday
behavior and health (stored as a list of named dataframes, which each contain
group assignments).
1 |
An R6Class
generator object
fitbit_daily
tibble dataframe of fitbit variables (for user account info provided) observed daily. Columns include:
date: unique for each row (date)
datetime: includes date and time, time is an arbitrary time, which is consistent for each day (date)
dateInForJavascriptLocalFormatting: chr
steps: total number of steps for that day (dbl)
distance: total distance for that day, in miles (dbl)
distanceKm: total distance for that day, in kilometers (dbl)
floors: total number of floors for that day (dbl)
minutesVery: minutes 'very active' that day (dbl)
caloriesBurned: calories (kcal) burned that day (dbl)
caloriesIntake: calories (kcal) consumed that day, user must input this, either into this data frame or into the fitbit (dbl)
restingHeartRate: resting heart rate in beats per minute (bpm) (dbl)
startTime: sleeping start time for that day (chr)
endTime: sleeping end time for that day (chr)
startDateTime: sleeping start date and time for that day (chr)
endDateTime: sleeping end date and time for that day (chr)
sleepDuration: sleep duration for that day, in minutes (int)
sleepDurationHrs: sleep duration for that day, in hours (dbl)
minAsleep: time asleep that day, in minutes (int)
minAsleepHrs: time asleep that day, in hours, derived from minAsleep (dbl)
minRestlessAwake: sleepDuration - awakeCount (int)
awakeCount: int
restlessCount: int
awakeDuration: int
restlessDuraton: int
restlessProp: proportion of sleep spent restless, calculated as restlessProp = (sleepDurationHrs - minAsleepHrs) / sleepDurationHrs * 100 (dbl)
sleepQualityScoreB: dbl
sleepQualityScoreA: int
sleepQualityGraphicPercentA: dbl
sleepQualityGraphicPercentB: dbl
sleepBucketTextB: one of "ok", "good", "great" (chr)
sleepBucketTextA: one of "ok", "good", "great" (chr)
clusters: list of chr
breaks: list of chr
fitbit_intraday
tibble dataframe of fitbit variables (for user account info provided) observed multiple times a day. Columns include:
date: unique for each row (date)
time: a combination of an arbitrary date ("1970-01-01") and the time of the observation, generally in 5 minute intervals (dttm)
datetime: includes date from 'date' and time from 'time' (dttm)
steps: number of steps in 15 minute interval (dbl)
distance: distance traveled in 15 minute interval, in miles (dbl)
distanceKm: distance traveled in 15 minute interval, in kilometers (dbl)
floors: number of floors went up and down in 15 minute interval (dbl)
activeMin: number of active minutes in 15 minute interval (dbl)
activityLevel: hypothesized activity level, one of: "SEDENTARY", "LIGHTLY_ACTIVE", "MODERATELY_ACTIVE", or "VERY_ACTIVE" (chr)
bpm: average heart rate in 5 minute interval (int)
confidence: one of -1, 1, 2, or 3 (int)
caloriesBurned: calories (kcal) burned in 5 minute interval (dbl)
defaultZone: chr
customZone: lgl
weight: weight, in lbs (dbl)
weightKg: weight, in kg (dbl)
util
tibble dataframe that maps each date in the date range to utility information about that date Columns include:
date: unique for each row (date)
datetime: date from 'date' and an arbitrary time (16:00:00) (dttm)
day_of_week: day of the week, with Sun as first (ord)
day_type: weekend or weekday (fctr)
month: month, with Jan as first (ord)
target_steps
the person's target number of steps (numeric) for each day (default 10,000)
start_date
start of user's date range of interest (Date object)
end_date
end of user's date range of interest (Date object)
user_info
provided user info, such as "age", "gender", "name" (list)
groupings
named list of dataframes, each with two columns - a known variable, and group, with the group assignment for observations where that variable has appropriate value
apple
tibble dataframe of user's provided Apple Health data. These columns depend on which columns are passed in by the user. However, these columns match fitbit columns:
datetime: dttm
steps: Original steps data for total number of steps in 60 minutes, but divided by 4 to match fitbit steps data, which is the total number of steps in 15 minutes (dbl)
distance: Average distance in 15 minutes in miles. Original distance data for total distance in 60 minutes, but divided by 4 to match fitbit distance data, which is the total distance in 15 minutes (dbl)
distanceKm: Average distance in 15 minutes in km. Original distance data for total distance in 60 minutes, but divided by 4 to match fitbit distance data, which is the total distance in 15 minutes (dbl)
floors: Average number of floors in 15 minutes. Original floors data for total number of floors in 60 minutes, but divided by 4 to match fitbit floors data, which is the total number of floors in 15 minutes(dbl)
bpm: average heart rate for the given hour, most users will not have this data (dbl)
addl_data
dataframe of data from another source provided by user
addl_data2
dataframe of data from another source provided by user
Person$new(fitbit_user_email, fitbit_user_pw, user_info = NA,
apple_data_file, target_steps, addl_data,
addl_data2, group_assignments, start_date,
end_date)
Creates a new Person
with specified data, and data from provided Fitbit account. If
provided, start_date and end_date must be characters with "
All defaults are NA
- user can provide sources of data
of interest.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library("lifelogr")
group_months <- data.frame("month" = c("Jan", "Feb", "Mar", "Apr", "May",
"Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec"),
"group" = c(0, 0, 0, 1, 1, 1, 1, 1,
1, 0, 0, 0))
ash <- Person$new(user_info = list("name" = "Ash", "age" = 26,
"gender" = "female"),
target_steps = 20000,
group_assignments = list("group_months" = group_months),
start_date = "2017-03-11",
end_date = "2017-03-12")
## Not run:
bailey <- Person$new(fitbit_user_email = "bailey@gmail.com",
fitbit_user_pw = "baileypw",
#apple_data_file = "apple.csv",
start_date = "2017-03-11",
end_date = "2017-03-12")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.