From 5b5b118c8de667cebc5ae6f486fc619de527dbc4 Mon Sep 17 00:00:00 2001 From: Anders Askeland Date: Sun, 5 May 2024 16:24:24 +0200 Subject: [PATCH 1/2] Added step to update mmash.R summarise calls Closes #49 --- sessions/dplyr-joins.qmd | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sessions/dplyr-joins.qmd b/sessions/dplyr-joins.qmd index f029193..eb59a42 100644 --- a/sessions/dplyr-joins.qmd +++ b/sessions/dplyr-joins.qmd @@ -645,6 +645,31 @@ mmash_link <- "https://physionet.org/static/published-projects/mmash/multilevel- dir_delete(here("data-raw/mmash/")) ``` +Next, as we have altered `import_multiple_files()` to use +`file_path` instead of `file_path_id`, we'll need to update how we +`group_by()` when creating `summarised_rr_df` and +`summarised_actigraph_df`. + +```{r data-raw-mmash-update} +#| filename: "data-raw/mmash.R" +summarised_rr_df <- rr_df |> + group_by(user_id, day) |> + summarise(across(ibi_s, list( + mean = \(x) mean(x, na.rm = TRUE), + sd = \(x) sd(x, na.rm = TRUE) + ))) |> + ungroup() + +summarised_actigraph_df <- actigraph_df |> + group_by(user_id, day) |> + summarise(across(hr, list( + mean = \(x) mean(x, na.rm = TRUE), + sd = \(x) sd(x, na.rm = TRUE) + ))) |> + ungroup() + reduce(full_join) +``` + Go into the `doc/learning.qmd` and cut the code used to create the `saliva_with_day_df` as well as the code to `full_join()` all the datasets together with `reduce()` and paste it at the bottom of the From 9a8e954a5ec24a498b7098ec36763275b76aca5f Mon Sep 17 00:00:00 2001 From: Anders Askeland Date: Sun, 5 May 2024 16:27:23 +0200 Subject: [PATCH 2/2] Changed reduce to use saliva_with_day_df Closes #51 --- sessions/dplyr-joins.qmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sessions/dplyr-joins.qmd b/sessions/dplyr-joins.qmd index f029193..a068190 100644 --- a/sessions/dplyr-joins.qmd +++ b/sessions/dplyr-joins.qmd @@ -599,7 +599,7 @@ saliva_with_day_df #| filename: "doc/learning.qmd" list( user_info_df, - saliva_df, + saliva_with_day_df, summarised_rr_df, summarised_actigraph_df ) |> @@ -662,7 +662,7 @@ saliva_with_day_df <- saliva_df |> mmash <- list( user_info_df, - saliva_df, + saliva_with_day_df, summarised_rr_df, summarised_actigraph_df ) |>