I have a function that returns a series of tables. I want to return them all as DT::datatable. However, I cannot get R to return these tables when they are in a list. They appear in RMarkdown files but not in knitted HTML files. Is it possible to have a table appear in an HTML document?
--- title: "Untitled" output: html_document ---
knitr::opts_chunk$set(echo = TRUE) library(tidyverse)
myfunc <- function(dataset){ return_list <- list() mytab <- DT::datatable(dataset) return_list$mytab <- mytab return(return_list) } myfunc(mtcars)
The table appears in the RMarkdown file:
but will not appear in knitted HTML files:
There are two ways to do this:
If you know the key in advance, just call it with the key
If you plan to make a longer list and want to print all tables in the list, use
tagList
from
{htmltools}