Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jcutlerbiostats opened this issue Jul 22, 2022 · 4 comments
Labels
Question ❓ Further information is requested

Comments

@jcutlerbiostats
Copy link

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?

@etiennebacher
Copy link
Member

I couldn't make it work with purrr::map() but here's an example that works with a for loop:

---
output: rmarkdown::pdf_document
---

```{r}
library(tidyverse)
library(parameters)

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

```{r results='asis'}
tmp <- mpg %>%
  select(cty, hwy) %>%
  names() %>%
  map(.f = function(response) {
    lm(
      formula(str_c(response, " ~ manufacturer")),
      data = mpg
    ) %>%
      model_parameters()
  })

for (i in tmp) {
  print(print_md(i))
}
```

@jcutlerbiostats
Copy link
Author

jcutlerbiostats commented Jul 25, 2022 via email

@strengejacke strengejacke added the Question ❓ Further information is requested label Aug 14, 2022
@strengejacke
Copy link
Member

Does this solve your issue and can we close this, or is there still something we could address?

@jcutlerbiostats
Copy link
Author

jcutlerbiostats commented Aug 14, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question ❓ Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants