DeclareDesign Community

Is it possible to get design code from a design diagnosis?

I have a simple question that may actually be a feature request.

For a lot of my designs, I end up saving the diagnose_design() output as an .rds file. For the most part, this works really great. However, a lot of the time as I’m experimenting with new designs I end up creating a lot of .rds files that are pretty similar and I’m having trouble keeping them organized.

Is there anyway to see the design code from a diagnosed design? I’m basically looking for some kind of equivalent to DesignLibrary::get_design_code()that I can use on a “diagnosed design” to see how it was created. Is there anyway to do this?

It’s an interesting idea, not something I’ve needed before. DesignLibrary::get_design_code() only works on DesignLibrary designs iirc, and recovering code from arbitrary designs is probably impossible.

Because diagnose_design is variadic, it would also need to track which code blocks go with which rows.

One idea is to hash the design, and include that hash as a column on the diagnostics, although there could be many false negatives (eg equivalent designs that hash differently) there shouldn’t be any false positives in normal usage.

I’d also recommend the https://github.com/r-lib/memoise package if you need to save a lot of diagnoses - if you are, for example, searching a grid of sample sizes and effect sizes, it can automatically push the diagnoses to disk, which can relieve a lot of memory pressure, and as a side benefit allow you to restart the grid in the middle.

1 Like

Ahh this it seems like this is actually a lot trickier than I anticipated. Thank you for the thoughtful answer and I suppose I’ll work on my file naming conventions! Keep me updated if you folks ever come up with an implementation!