emitanaka / edibble

An R-package that encapsulate elements of experimental design for better planning, management, and workflow
https://edibble.emitanaka.org
Other
215 stars 14 forks source link

Allow nesting based on other variables #68

Open emitanaka opened 11 months ago

emitanaka commented 11 months ago

Something like:

design() %>% 
  set_units(group = 2,
                   subject = nested_in(group, 5),
                   cells = nested_in(subject, .based_on = group,
                                                           1 ~ 2,
                                                           2 ~ 4))
gavin-kelly-1 commented 11 months ago

Looks really useful - perhaps an even more general nested_in(subject, ~ifelse(group=="group1",2,4)) where formulae without a lhs would be evaluated to provide the nested levels.

emitanaka commented 10 months ago

I agree with keeping it general like you say. Let me think about how this affects the underlying graph structure (and subsequently the suggested design_model()). Part of the problem is that you can end up specifying a crossed structure but it won't be encoded as such in the system and hence causes issues downstream. So in that sense, we might need some constrain so it doesn't allow users to go too wild.