I would like to ask if it is possible to let the user manually adjust the column widths by clicking on the column and dragging it. If so, how?
You can do that with the colResize plugin. Download the js file and the css file. In the code below, path/to/colResize is the path to the folder containing these two files. If you use an absolute path, you don't need normalizePath.
library(DT)
library(htmltools)
dep <- htmlDependency(
name = "colResize",
version = "1.6.1",
src = normalizePath("path/to/colResize"),
script = "jquery.dataTables.colResize.js",
stylesheet = "jquery.dataTables.colResize.css",
all_files = FALSE
)
dat <- iris
dtable <- datatable(
dat,
options = list(
colResize = list()
)
)
deps <- dtable$dependencies
deps <- c(deps, list(dep))
dtable$dependencies <- deps
dtable