openpharma / crmPack

Object-Oriented Implementation of CRM Designs
https://openpharma.github.io/crmPack/
20 stars 10 forks source link

Add indentation when `knit_print()` stopping rule list #836

Closed fenguoerbian closed 5 months ago

fenguoerbian commented 5 months ago

Summary

knit_print() is a convenient way of rendering reader-friendly output of crmPack objects in Rmd report. But I see some improvement in the way of knit_print.StoppingList().

Currently there is no indentation added to the rendered stopping rule list. So if there are nested stopping rule list, they will all be at the same level, such as what is shown in the vignette, or an example as follows:

tmp_stop <- crmPack::.DefaultDesign()@stopping
#> Registered S3 method overwritten by 'crmPack':
#>   method       from  
#>   print.gtable gtable
crmPack:::knit_print.StoppingAny(tmp_stop) |>
    cat()
#> If any of the following rules are `TRUE`:
#> 
#> -  If all of the following rules are `TRUE`:
#> 
#> -  ≥ 3 cohorts dosed: If 3 or more cohorts have been treated.
#> 
#> 
#> -  P(0.2 ≤ prob(DLE | NBD) ≤ 0.35) ≥ 0.5: If the probability of toxicity at the next best dose is in the range [0.20, 0.35] is at least 0.50.
#> 
#> 
#> 
#> 
#> -  ≥ 20 patients dosed: If 20 or more participants have been treated.

Created on 2024-06-25 with reprex v2.1.0

The rendered output of these rules are all at the same level.

If any of the following rules are TRUE:

What's the problem this feature will solve?

I think some indentation at the beginning of these lists are necessary so the rendered output one can easily see which rules belongs to which list, such as

If any of the following rules are TRUE:

Currently I'm using a customized knit_print() that pads additional spaces to the begining of the output accordingly to achieve this. But I believe this feature would improve the readability and is worth considering to add into the package. If you like the idea I can submit a PR.

This issue can be related to #803 and #774

Puzzled-Face commented 5 months ago

Thank you for making this suggestion. I agree it's necessary - it's been on my "to do" list for a while. I will review asap.

Puzzled-Face commented 5 months ago

A couple of "nice-to-haves":

fenguoerbian commented 5 months ago

Thank you for this quick reply.