commit 0df6ac15aeebcf106683bdbcc78aad84170c9159 Author: ergz Date: Thu Mar 30 02:28:33 2023 -0700 initial diff --git a/analysis.R b/analysis.R new file mode 100644 index 0000000..dbe4b0a --- /dev/null +++ b/analysis.R @@ -0,0 +1,37 @@ +library(dplyr) +library(tidyr) +library(googlesheets4) +library(lubridate) +library(ggplot2) + +sheet_url <- "https://docs.google.com/spreadsheets/d/1-VVII_7AJ-6J6Uja_oDAw2F3dMASA4SIA8CWBQQWkuo/edit#gid=0" + +mateo_feeding_raw <- googlesheets4::read_sheet(sheet_url, sheet = "bottle feeding") |> + filter(!is.na(Date)) +mateo_growth_raw <- googlesheets4::read_sheet(sheet_url, sheet = "weight") + + +# Feeding --------------------- + +mateo_feeding <- mateo_feeding_raw |> + filter(!is.na(Date)) |> + transmute( + date_time = as_datetime(paste0(as_date(Date), " ", format(Time, "%H:%M:%S"))), + type = Type, + amount_grams = `Amount (g)`, + consumed = ifelse(Consumed > amount_grams, amount_grams, Consumed)) + + +mateo_feeding |> + mutate(prop_consumed = consumed / amount_grams) |> + ggplot(aes(prop_consumed, fill = type)) + geom_histogram(position = "dodge", binwidth = .25) + + + + +# Weight ---------------------- + +mateo_growth_raw |> + select(datetime = TIme, weight_oz = `Weight (oz)`, weight_lbs = `Weight (lbs)`) |> + mutate(oz_diff = weight_oz - lag(weight_oz)) +