Is it possible to do something along the following lines with modelr::permute, or if not I guess it's also a potential suggestion!
Using mtcars, would it be possible to first group_by, say, gear and carb value, and then only shuffle am values between rows with matching gear and carb values? that's as opposed to shuffling am values between all rows
I run into an error attempting the following (though that could also be due to the function I create)
df <- mtcars %>%
group_by(gear, carb) %>% # no error once this line is commented out
modelr::permute(8, am)
df$perm %>%
map_df(function(x){
x$data %>%
mutate(am = x$idx)
})
# Error: Column `am` must be length 3 (the group size) or one, not 32
Is it possible to do something along the following lines with modelr::permute, or if not I guess it's also a potential suggestion!
Using mtcars, would it be possible to first group_by, say, gear and carb value, and then only shuffle am values between rows with matching gear and carb values? that's as opposed to shuffling am values between all rows
I run into an error attempting the following (though that could also be due to the function I create)