nutterb / pixiedust

Tables So Beautifully Fine-Tuned You Will Believe It's Magic.
178 stars 18 forks source link

dust output in Viewer instead of in html output when using render #96

Closed HelenaEdlund closed 6 years ago

HelenaEdlund commented 6 years ago

Hello again,

I am using dust() to print tables within an rmarkdown document. When I knit it using the knit button it works fine and the tables are included. However, when I try to use the rmakrdown::render to generate this document from another R script, the tables show up in the Viewer and are not included in the document. Is this a bug or is there some settings I should change for dust to work with the render function?

Thanks, Helena

nutterb commented 6 years ago

This was encountered in #85 . as I've done more research, I've learned there are multiple things you can do. In order of most to least effective

  1. in rmarkdown::render, use envir = new.env (). This will ensure that the document is knit in a separate environment, not in your interactive session. (I haven't yet tried this, but I'm fairly confident it will work)
  2. In your .Rmd, use options (pixie_interactive =FALSE). This will bypass the interactivity check. it requires pixiedust 0.8.0 (now on CRAN)
  3. Use %>% print (asis = FALSE) %>% cat() after each table with the chunk option results = 'asis'
nutterb commented 6 years ago

I just got around to my own testing. Option 1 doesn't work like I had hoped. Option 2 does work and is probably easiest.

This looks related to https://github.com/yihui/knitr/issues/926, so it looks like I need to do some more work on my print methods.

HelenaEdlund commented 6 years ago

Thanks, I'll use option 2 for now then!