easystats / easystats/parameters

What's making print_md() work outside a loop and then not work in a loop?

Open
#749 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Question :question:
Dominant language
R
Stars
499
Forks
45
Avg merge
3d 1h
Merged PRs (30d)
3

Description

If I use print_md() in an Rmd document to be knitted to PDF, it works just fine (the rendered table looks like beautiful latex output), until I use it in a loop. Then unpredictable things can happen, but it's usually just the un-pretty console output. Below is a reprex:

library(tidyverse)
library(parameters)

lm(
cty ~ manufacturer,
data = mpg
) %>%
model_parameters() %>%
print_md(caption = "City miles")

mpg %>% select(cty,hwy) %>% names() %>%
map(.f = function(response){
lm(
formula(str_c(response," ~ manufacturer")),
data = mpg
) %>%
model_parameters() %>%
print_md(caption = response)
})

Using print_md() inside purrr::map() prints out un-pretty console-esque tables in PDF.

Is there a fix for this or something I'm not doing right?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reprex in the issue and compare print_md() called directly with the same call inside purrr::map() while knitting to PDF. Trace why the loop produces console-style tables; done when mapped results render as formatted LaTeX tables like the direct call.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.