Chapter 2 Data preparation

tube_test_data <- read_csv("data/tube_tests.csv") %>%
      mutate(mouse = substr(mouse, 1, 5)) %>%
      mutate(cage_id = paste0("C", cage_id)) %>%
      mutate(time = factor(case_when(
          treatment == "t1" ~ 1,
          treatment == "t2" ~ 2,
          treatment == "t3" ~ 3,
          treatment == "t4" ~ 4,
          treatment == "t5" ~ 5,
          treatment == "t6" ~ 6,
          TRUE ~ NA))) %>%
      arrange(time)
tube_test_data %>%
  head() %>%
  tt() |> 
      style_tt(j = 1, color = "#6e0f0f", background = "#e39d9d") |> 
      style_tt(i = 0, color = "white", background = "#a52929")
tinytable_afmo8rhzlkwjqr1r40ld
trial_id tubetest_id test_number mouse tube_win_position date win_loss_binomial cage_id treatment tube_replicate sex row_number time
TT0121 03M_t1_R1 T1 C03M4 A 2/10/2020 0 C03 t1 R1 male 138 1
TT0122 03M_t1_R1 T2 C03M3 B 2/10/2020 0 C03 t1 R1 male 139 1
TT0123 03M_t1_R1 T3 C03M1 A 2/10/2020 0 C03 t1 R1 male 140 1
TT0124 03M_t1_R1 T4 C03M1 B 2/10/2020 0 C03 t1 R1 male 141 1
TT0125 03M_t1_R1 T5 C03M4 B 2/10/2020 0 C03 t1 R1 male 142 1
TT0126 03M_t1_R1 T6 C03M4 A 2/10/2020 0 C03 t1 R1 male 143 1