Any way to set knitr::kable() as global option for all tables in a qmd file? #933
Answered
by
jjallaire
jeweljohnsonj
asked this question in
Q&A
-
Is there any way to set knitr::kable() as the default global option way of showing tables in a rendered file? |
Beta Was this translation helpful? Give feedback.
Answered by
jjallaire
May 19, 2022
Replies: 2 comments 9 replies
-
Here is one way to do it: ```{r}
#| include: false
knit_print.data.frame = function(x, ...) {
res = paste(c("", "", knitr::kable(x)), collapse = "\n")
knitr::asis_output(res)
}
registerS3method(
"knit_print", "data.frame", knit_print.data.frame,
envir = asNamespace("knitr")
)
```
```{r}
mtcars
``` That's the low-level way, the ```{r}
#| include: false
library(printr)
```
```{r}
mtcars
``` |
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
jjallaire
-
For using with R, there is now a So you can now set |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is one way to do it:
That's the low-level way, the
printr
package also implements this by default: