Returns a sequence of DT::datatables in a list of knitted HTML documents
P粉510127741
P粉510127741 2023-09-15 13:55:12
0
1
863

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:

P粉510127741
P粉510127741

reply all (1)
P粉872182023

There are two ways to do this:

If you know the key in advance, just call it with the key

myfunc(mtcars)$mytab

If you plan to make a longer list and want to print all tables in the list, usetagListfrom{htmltools}

htmltools::tagList(myfunc(mtcars))
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!