-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Labels
Question ❓
Further information is requested
Comments
I couldn't make it work with ---
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))
}
``` |
Wow that’s great thank you!
…On Mon, Jul 25, 2022 at 2:56 AM Etienne Bacher ***@***.***> wrote:
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))
}```
—
Reply to this email directly, view it on GitHub
<#749 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWGYUPA25XUSI7EVW7QZRBLVVZCDDANCNFSM54MVJBWA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Does this solve your issue and can we close this, or is there still something we could address? |
I guess just one other thing I'm struggling to understand is how to add
table captions in the loop. I've tried this but it doesn't work:
```{r}
tmp_captions <- mpg %>%
select(cty, hwy) %>%
names() %>% str_c(" miles")
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),caption = tmp_captions[i])
}
```
…On Sun, Aug 14, 2022 at 3:02 AM Daniel ***@***.***> wrote:
Does this solve your issue and can we close this, or is there still
something we could address?
—
Reply to this email directly, view it on GitHub
<#749 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWGYUPH6V4UCFH6A3HOPD2TVZCRXPANCNFSM54MVJBWA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
The text was updated successfully, but these errors were encountered: