Approach for repeated permutation test?



Is there an idiom for doing repeated calls to resample_permutation? I tried, on an already nested frame,

df %>%
  mutate(perms = map(.$dfcolumn, ~replicate(1000, resample_permutation(., c('perm_column'))) %>%
  unnest(perms, .drop=F)

This seems to do the permutations, but then it is in the wrong form for unnesting. I noodled around a bit with enframe and transposing, but I haven't found an elegant solution yet.

I want to:

  1. Use nest() to create a nested data frame
  2. Repeatedly shuffle/permute one column of the nested frame
  3. Model fit all the shuffled copies
  4. Summarize