title: Shorten column names, provide tooltip on hover of full name
body: <p>I have a <code>datatable</code> that I'm displaying within a simple R Shiny app. I have many long column names that prevent me from maximally using the horizontal screen space. I would like to do two things:</p>
  
  <ol>
  <li>Abbreviate or truncate each column name so that each column is skinny (compared to the current state, see MRE below). Ideally, I would like each column to be only as wide as the cell which contains the longest string of data (e.g. in column 1, below, the column width should be no wider than the amount of space that 'AAAAA' occupies) . By default, <code>datatable</code> tables look quite chunky, and they don't make maximal use of screen real estate.</li>
  <li>On hovering over the abbreviated/truncated column name, the user is presented with the full-length name.</li>
  </ol>
  
  <pre><code>x&lt;-data.frame(a_long_column_name = c("AAAAA", "AAA", "AAA", "BBB", "BBB", "CCC"), 
                a_really_unnecessarily_long_column_name = c("Alice", "Alice", "Alice", "Bob", "Bob", "Charlie"),
                a_silly_and_unnecessarily_long_column_name_which_i_cant_change = c("T-Shirt", "Pants", "Socks", "Socks", "Pants", "T-Shirt"),
                another_silly_and_unnecessarily_long_column_name_which_i_cant_change = c("Red", "Orange", "Green", "Blue", "Purple", "Yellow"))
  
  
  library(shiny)
  library(tidyverse)
  library(DT)
  
  runApp(list(
  
    ui = basicPage(
      DT::dataTableOutput('mytable')
    ),
  
    server = function(input, output) {
      output$mytable = DT::renderDataTable({
        x&lt;-datatable(x, selection = "single", filter = "top")
      })
    }
  ))
  </code></pre>
  
  <p>I believe it's possible to abbreviate column names with base <code>abbreviate()</code> for example:</p>
  
  <pre><code>colnames(x) &lt;- sapply(names(x), function(x) abbreviate(x, minlength = 16))
  </code></pre>
  
  <p>but the abbreviations become mostly unreadable and I still can't figure out how to implement the hover functionality as outlined in Point 2, above.</p>
  
  <p>I think the best solution might be to truncate each column name by x number of characters (e.g. if x = 12 then Column 1 becomes 'a_long_colum...' and Column 2 would become 'a_really_unn...')</p>
  
  <p>At this point I'm open to any and all ideas/solutions.</p>
  
  <p>Thanks!</p>