R:tr()、th() 和 thead() - 它们属于哪个包?

R: tr(), th() and thead() - what package do they belong to?

我用自定义容器构建了一个 DT table,类似于 here(第 2.6 - 2.6 点自定义 Table 容器)。我正在打包使用此 table 的闪亮应用程序,我想找出用于定义 [=] 的包 th()tr()thead() 函数14=]对象,属于..?

??thead等。向我指出各种 DT 函数,但 ?DT::thead() returns 没有文档。感谢指点!

你应该注意到在 sketch 的定义中他们调用 htmltools::withTags 这相当简单

function (code) 
{
    eval(substitute(code), envir = as.list(tags), enclos = parent.frame())
}
<bytecode: 0x000001c832d09200>
<environment: namespace:htmltools>

需要注意的是,它要用到substitute和envir = as.list(tags)。如果我们看一下 tags,它是一个包含以下名称的列表 objects/functions:

> names(tags)
  [1] "a"           "abbr"        "address"     "area"        "article"     "aside"       "audio"      
  [8] "b"           "base"        "bdi"         "bdo"         "blockquote"  "body"        "br"         
 [15] "button"      "canvas"      "caption"     "cite"        "code"        "col"         "colgroup"   
 [22] "command"     "data"        "datalist"    "dd"          "del"         "details"     "dfn"        
 [29] "div"         "dl"          "dt"          "em"          "embed"       "eventsource" "fieldset"   
 [36] "figcaption"  "figure"      "footer"      "form"        "h1"          "h2"          "h3"         
 [43] "h4"          "h5"          "h6"          "head"        "header"      "hgroup"      "hr"         
 [50] "html"        "i"           "iframe"      "img"         "input"       "ins"         "kbd"        
 [57] "keygen"      "label"       "legend"      "li"          "link"        "mark"        "map"        
 [64] "menu"        "meta"        "meter"       "nav"         "noscript"    "object"      "ol"         
 [71] "optgroup"    "option"      "output"      "p"           "param"       "pre"         "progress"   
 [78] "q"           "ruby"        "rp"          "rt"          "s"           "samp"        "script"     
 [85] "section"     "select"      "small"       "source"      "span"        "strong"      "style"      
 [92] "sub"         "summary"     "sup"         "table"       "tbody"       "td"          "textarea"   
 [99] "tfoot"       "th"          "thead"       "time"        "title"       "tr"          "track"      
[106] "u"           "ul"          "var"         "video"       "wbr"   

其中每一个都具有基本相同的形式:

> tags$thead
function (...) 
tag("thead", list(...))
<bytecode: 0x000001c82c4a2678>
<environment: namespace:htmltools>

所以它基本上只是一种方便的方式来调用带有指定标签的tag函数。直接调用的例子:

> tag("thead", "This is my thead")
<thead>This is my thead</thead>