I've been using kable
and kableExtra
to good effect, and have been creating tables that then display in-line in the R Markdown notebook (as well as knitting to html). Now, this morning I re-installed R and RStudio... and now the tables only appear in the viewer pane and I get this weird code in-line as output -
<table class="table table-striped" style="width: auto !important; margin-left: auto; margin-right: auto;">
<thead>
<tr>
<th style="text-align:left;"> </th>
[this goes on for many lines]
It does still work when knitting, it's just annoying that it's showing this in-line instead of the table. Interestingly, it does seem to show the table when I just call kable
, but it seems like it's kableExtra
that isn't liking it.
I've updated the packages, manually uninstalled and then reinstalled the packages, and even completely removed R and R Studio before installing them from scratch. I'm sure that it's not my code that is the problem, because it's doing this even for a data script that I haven't modified and which was working perfectly yesterday.
Here is a reproducible example using the mtcars
dataset. I think this would need to be run in an R Markdown Rmd file, to show the problem I'm facing.
library(tidyverse)
library(knitr)
library(kableExtra)
df <- head(mtcars)
kable(df, format = "html", digits = 2) %>%
kable_styling(bootstrap_options = "striped", full_width = F)
This is actually one of the examples used in the kableExtra
documentation - and to repeat - the code is working when knitting to html, it just isn't showing in the actual document anymore, and it was yesterday.
Any advice greatly appreciated.
I can feel your sadness. :P
I didn't think about the notebook too much when I made this preview feature in kableExtra 0.7.0. It was my bad.
I just fixed it in the dev version and will push a fix patch to CRAN in a few days. You can wait for CRAN update but if you can't wait to get rid of the raw HTML results, consider install from github for now.
With the new feature, now your table in notebook will have bootstrap loaded. You will like it. ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With