2
votes

I use DT::datatable in lots of HTML rmarkdown reports that eventually get copied into other documents (e.g., Word, Excel) for final formatting/formatting. The issue I'm having though is that when I use the "copy" button extension to copy and paste from DT::datatable() into the other document is that it has this annoying title that gets pasted along with the table.

For example, if I use the "copy" button from this:

df <- data.frame(x = 1:5, y = letters[1:5])

DT::datatable(df, 
              extensions = "Buttons",
              rownames = F, 
              options = list(dom = 'Blfrtip', buttons = 'copy'))

I get this:

Exported data

x   y
1   a
2   b
3   c
4   d
5   e

Is it possible to not have the Exported data and blank line below it, and to only have this output when I paste?

x   y
1   a
2   b
3   c
4   d
5   e
1

1 Answers

1
votes

You have to use title = NULL in the list of lists passed to the buttons arguments.

df <- data.frame(x = 1:5, y = letters[1:5])

DT::datatable(df, 
              extensions = "Buttons",
              rownames = F, 
              options = list(dom = 'Blfrtip', 
              buttons = list(list(extend = 'copy', title = NULL))
))