0

How do I drop the row numbers when displaying R tibble through the DT package?

The options = list(rownames = FALSE) argument doesn't seem to work, I also "made up" options = list(rownumbers = FALSE) and that didn't work. I messed around with things like select(2:everything()) but that did not work either. Maybe piping in remove_rownames() at then end will work... it does not, or perhaps as.data.frame() piped at the end... Nope.

library(tidyverse)
library(DT)
datatable(mtcars %>% head() %>% as_tibble(), options = list(rownames = FALSE))

tibble with row numbers

Display name
  • 4,153
  • 5
  • 27
  • 75
  • See `help("datatable")`. There is a `rownames = TRUE` default argument. –  Nov 04 '20 at 16:03

1 Answers1

2
library(tidyverse)
library(DT)
datatable(mtcars %>% head() %>% as_tibble, rownames = FALSE)

You just need to rearrange the parenthesis, so that the rownames value is changed for datatable and not for the as_tibble call.

enter image description here

Matt
  • 7,255
  • 2
  • 12
  • 34