I tried to use this for one of the problems I am working on and I am running into the following error. I know that this is by design
The value in 'data[[cat_col]]' must be
* constant within each ID.
Is it possible to relax your restriction? It is very possible that two measurements from the same group (or ID) could be different. For example, a subject could get two different diagnoses, and we want to make sure they are still either only in training or test, and the diagnoses do count to the total. In the case I'm looking at, the IDs are studies, and examples of both classes can be within in a single study.
E.g., using your df as defined in the cross-validation with group data vignette, let's just change:
df[3, "diagnosis"] <- "b"
parts <- partition(df, p = 0.2, id_col = "participant", cat_col = 'diagnosis')