insightsengineering / cards

CDISC Analysis Results Data
https://insightsengineering.github.io/cards/
24 stars 0 forks source link

`shuffle_ard()` doesn't properly coerce factor variables #232

Closed bzkrouse closed 2 months ago

bzkrouse commented 2 months ago

In the following example, if we make RACE a factor and then perform shuffle_ard(), it is correctly coerced to character (to be stacked up with ETHNIC) but the values are incorrect (1,2,3... instead of the factor levels).

adsl_ <- ADSL |>
  dplyr::mutate(RACE = factor(RACE))

ard_categorical(
  data = adsl_,
  by = TRT01A,
  variables = c(RACE, ETHNIC)
) |>
  shuffle_ard()