问题 I stat apologize for the long question, but after quite a while I couldn't figure out a solution myself. I have this toy dataframe set.seed(23) df <- tibble::tibble( id = paste0("00", 1:6), cond = c(1, 1, 2, 2, 3, 3), A_1 = sample(0:9, 6, replace = TRUE), A_2 = sample(0:9, 6, replace = TRUE), A_3 = sample(0:9, 6, replace = TRUE), B_1 = sample(0:9, 6, replace = TRUE), B_2 = sample(0:9, 6, replace = TRUE), B_3 = sample(0:9, 6, replace = TRUE), C_1 = sample(0:9, 6, replace = TRUE), C_2 = sample