Skip to content

Rmd partials #28

@rubenarslan

Description

@rubenarslan

I like the concept of Rmd partials for repetitive things I do (like summaries of models, robustness checks, making a codebook for the items in a survey).

But I'm not sure I'm using them right, because it seems a bit hacky at times.

To give an example: here, you can see where I used one to summarise a regression with some plots and headlines (this is a simplified example, it's usually a bit more involved).

The partial itself: https://rubenarslan.github.io/repro_web_stack/_regression_summary.html
Used: https://rubenarslan.github.io/repro_web_stack/3_analyses.html

Here are things that felt a bit hacky:

  • I needed to set options(knitr.duplicate.label = 'allow') globally if I want named chunks.
  • I "needed" this convenience function: https://github.com/rubenarslan/formr/blob/master/R/rmarkdown_options.R#L234 so that it's rendered "asis" and so that the environment is the calling environment for knit_child.
  • I wanted to call the partials from a function (could simply be knit_print.lm or something more "custom" like I use now). So it takes arguments from the calling environment, but I cannot specify these in the Rmd file. I tried using parameters, but I think knitr:knit_child does not support them.

I was thinking of packaging some partials that I've made for myself, but wanted to collect your opinion on best practices first. Should I maybe use an htmlwidget-style approach for this as this is more "standard"? I like about the knit_child approach that I can treat it like text, concatenate several etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions