Giter VIP home page Giter VIP logo

Comments (2)

phillc73 avatar phillc73 commented on May 27, 2024

Both dom and tableTools need to be part of options=list(). In your example, they are external to it.

Try this:

library(DT)
# a custom table container
sketch = htmltools::withTags(table(
  class = 'display',
  thead(
    tr(
      th(rowspan = 2, 'Current Industry'),
      th(colspan = 3, 'Share of Workers'),
      th(colspan = 3, 'Share of Workers w/a Pro Cert (Q1)'),
      th(colspan = 3, 'Share of Workers w. Certificate (Q10)')
    ),
    tr(
      lapply(rep(c('Overall', 'Male', 'Female'), 3), th)
    )
  )
))
table1 = structure(c(4570, 8980, 6e-04, 0.0067, 0.8455, 0.1154, 0.1545, 
                     0.8846, 0.6998, 0.6348, 0.9416, 0.1349, 0.0584, 0.8651, 0.1742, 
                     0.2279, 1, 0.1568, 0, 0.8432), .Dim = c(2L, 10L), .Dimnames = list(
                       NULL, c("industry", "Overall1", "Male1", "Female1", "Overall2", 
                               "Male2", "Female2", "Overall3", "Male3", "Female3")))

datatable(table1, extensions = 'TableTools', 
          filter = 'top', container = sketch, caption = 'Table 1: Certification by industry',
          rownames = FALSE, 
          options = list(pageLength = 15, lengthMenu = c(5, 10, 15, 50, 100),
                         dom = 'T<"clear">lfrtip',
                         tableTools = list(sSwfPath = copySWF())
                         )
          ) %>%
  formatPercentage(2:10, 2)

Hope it helps.

from dt.

yihui avatar yihui commented on May 27, 2024

I think @phillc73 is exactly correct. Thanks!

from dt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.