Here is a quick way to do this in RStudio
view_kable <- function(x, ...){
tab <- paste(capture.output(kable(x, ...)), collapse = '\n')
tf <- tempfile(fileext = ".html")
writeLines(tab, tf)
rstudio::viewer(tf)
}
view_kable(head(df[,1:9]), format = 'html', table.attr = "class=nofluid")
If the kable
function can return an object of class kable
, then one could rename view_kable
as print.kable
in which case merely calling the kable
function would open the table in the viewer. If you think this is useful, please go ahead and file a feature request on the knitr
github page.