How to include pre-rendered tables? #11067
-
DescriptionI need to include tables that are produced externally - is there a good (simple) way of doing that? The tables are also output from R (either {gt} or {tinytable}). I did find #6602 about HTML, but there didn't seem to be an easy way like:
I guess the question implicitly also asks: Which format should I export to for highest portability into Quarto? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 20 replies
-
Did you actually try? The thread you mentioned is more than one year old. Note that it won't work because the code you are showing is not valid as it does not respect the shortcode syntax. |
Beta Was this translation helpful? Give feedback.
-
Here's an example to write an html fragment using gt:
I can't combine the html raw block in this example because it tries to include it before the R code runs, but it works in a separate document. |
Beta Was this translation helpful? Give feedback.
-
In conclusion (as of today), future fellow R strugglers, who need to output your tables and import them into a Quarto project:
BONUS:
Many thanks @mcanouil and @gordonwoodhull for the help! |
Beta Was this translation helpful? Give feedback.
-
Out of curiosity, why do you need to export to HTML in the first place ? If those are produced by R function you could use it directly in a quarto document. Either the data and the code, or save the R table object to a file (like Just curious about the workflow that pushed a export HTML to import HTML Thanks. |
Beta Was this translation helpful? Give feedback.
In conclusion (as of today), future fellow R strugglers, who need to output your tables and import them into a Quarto project:
gt::gtsave()
, use one of the ways in #11067 (reply in thread).{=html}
block:BONUS:
If you want to be able to reference the table and give it a caption, you can simply place the
{=html}
block inside a table environment:Many thanks @mcanouil and @gordonwoodhull for the help!