Type: | Package |
Title: | Parse Output from 'BabyTime' Application |
Version: | 0.1.0 |
Author: | Dann Hekman [aut, cre] |
Maintainer: | Dann Hekman <dannhek@gmail.com> |
Description: | 'BabyTime' is an application for tracking infant and toddler care activities like sleeping, eating, etc. This package will take the outputted .zip files and parse it into a usable list object with cleaned data. It handles malformed and incomplete data gracefully and is designed to parse one directory at a time. |
License: | MIT + file LICENSE |
Depends: | dplyr (≥ 1.1.4), glue (≥ 1.8.0), janitor (≥ 2.2.0), lubridate (≥ 1.9.3), methods (≥ 4.4.1), R (≥ 4.4.0), readr (≥ 2.1.5), snakecase (≥ 0.11.1), stringr (≥ 1.5.1) |
Imports: | utils |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
Encoding: | UTF-8 |
Language: | en-US |
LazyData: | true |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-01-15 01:22:38 UTC; djh |
Repository: | CRAN |
Date/Publication: | 2025-01-16 10:30:05 UTC |
Sample 'BabyTime' Data List Database
Description
Sample output from 'read_one_bt_activity_file' and 'clean_bt_list_db'. A "Clean BT List DB" object.
Usage
bt_list_db
Format
## 'bt_list_db' A "Clean BT List DB" object.
- pumping
Breast Pumping Data (Data Frame; 3 obs. 8 variables)
- pee
Diaper Change Data (Data Frame; 1 obs. 5 variables)
- pumped_milk
Drinking Breast Milk from Bottle Data (Data Frame; 3 obs. 6 variables)
- medicine
Medications Given Data (Data Frame; 1 obs. 6 variables)
- baby_food
Data on Eating Solids (Data Frame; 1 obs. 6 variables)
- sleep
Sleep Data. Includes both Night and Daytime Sleep (Data Frame; 5 obs. 5 variables)
- breastfeeding
Breast Feeding Data (Data Frame; 4 obs. 7 variables)
Source
Synthetic Data used to test this package. Based loosely on author's personal data.
Clean BabyTime List DB File
Description
Clean BabyTime List DB File
Usage
clean_bt_list_db(list_db)
Arguments
list_db |
output from 'read_one_bt_activity_file' |
Value
a Clean BT List DB object
Examples
data_dir <- system.file('extdata', package = 'babyTimeR')
baby_dann_db <- read_one_bt_activity_file(
infile = file.path(data_dir, 'activity_Dann_202411.txt')
) |>
clean_bt_list_db()
names(baby_dann_db)
Combine two 'BabyTime' List Databases (DBs)
Description
Generally not needed if you parse all files at once, but can be useful if combining data extracted at multiple times or across multiple directories
Usage
combine_clean_bt_list_dbs(la, lb)
Arguments
la |
a Clean BT List DB object |
lb |
another Clean BT List DB object |
Value
a Clean BT List DB object that contains all elements from 'la' and 'lb'
Examples
data_dir <- system.file('extdata', package = 'babyTimeR')
baby_dann_db_nov <- read_one_bt_activity_file(
infile = file.path(data_dir, 'activity_Dann_202411.txt')
) |>
clean_bt_list_db()
baby_dann_db_dec<- read_one_bt_activity_file(
infile = file.path(data_dir, 'activity_Dann_202412.txt')
) |>
clean_bt_list_db()
baby_dann_db <- combine_clean_bt_list_dbs(
baby_dann_db_nov,
baby_dann_db_dec
)
Process One Directory of 'BabyTime' Activity Files
Description
Only works with with .zip files
Usage
process_one_directory(directory, remove_txts = TRUE, verbose = TRUE)
Arguments
directory |
directory with activity files in it |
remove_txts |
boolean. whether to remove txt files before processing |
verbose |
boolean. print out processing details? |
Value
Clean BT List DB object (and also write it to the 'out' RDS file)
Examples
data_dir <- system.file('extdata', package = 'babyTimeR')
if (file.exists('parsed_data.RDS')) {
baby_dann_db <- readRDS('parsed_data.RDS')
} else {
baby_dann_db <- process_one_directory(
directory = data_dir,
remove_txts = FALSE
)
}
Read One 'BabyTime' Activity File
Description
Read line-by-line and parse into a "database" in a list.
Usage
read_one_bt_activity_file(infile, list_db = NULL, verbose = FALSE)
Arguments
infile |
a .zip or .txt file with the format activity_BabyName_yyyymm as the 'BabyTime' app exports data. |
list_db |
a 'Raw BT List DB' object on which to append data. If none exists, this will create a new 'Raw BT List DB' object. |
verbose |
whether or not to write out progress messages. |
Value
a populated 'Raw BT List DB' object
Examples
data_dir <- system.file('extdata', package = 'babyTimeR')
baby_dann_db <- read_one_bt_activity_file(
infile = file.path(data_dir, 'activity_Dann_202411.txt')
) |>
clean_bt_list_db()
names(baby_dann_db)