38 lines
1.1 KiB
R
38 lines
1.1 KiB
R
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))
|
|
|