options

{handsontable} has 3 main functions to help you configure options for the table:

handsontable

handsontable() allows you to configure table-wide options.

data

  • your table data. must be a data.frame or a matrix object.
handsontable(data = iris)

width

  • sets the width of the table
handsontable(
  data = iris[1:3, ],
  width = 400,
  adaptiveHeight = TRUE
)

height

  • sets the height of the table
handsontable(
  data = iris[1:50, ],
  height = 200
)

adaptiveHeight

  • if TRUE the table’s height adapts to fit it’s contents. useful when you want to show the full table regardless of the number of rows in your data.

  • if TRUE, overrides the height parameter.

  • adaptiveHeight = FALSE:

handsontable(
  data = mtcars,
  rowHeaders = FALSE,
  adaptiveHeight = FALSE
)
  • adaptiveHeight = TRUE:
handsontable(
  data = mtcars,
  rowHeaders = FALSE,
  adaptiveHeight = TRUE
)

colHeaders

  • column names to use.
  • can be a logical (TRUE or FALSE) or a character vector of column names to use.
  • colHeaders = TRUE uses the column names of the data:
handsontable(
  data = iris[1:3, ],
  colHeaders = TRUE,
  adaptiveHeight = TRUE
)
  • colHeaders = FALSE omits the column names of the data and uses excel-like naming for the columns ie. “A”, “B”, “C”, etc.
handsontable(
  data = iris[1:3, ],
  colHeaders = FALSE,
  adaptiveHeight = TRUE
)
  • you can as well use a character vector to rename the rendered columns. this doesn’t change the column names of the underlying data.
handsontable(
  data = iris[1:3, ],
  colHeaders = c(
    "Sepal Length",
    "Sepal Width",
    "Petal Length",
    "Petal Width",
    "Species"
  ),
  adaptiveHeight = TRUE
)

rowHeaders

  • row names to use.
  • can be a logical (TRUE or FALSE) or a character vector of row names to use.
  • rowHeaders = TRUE uses row names of the data:
handsontable(
  data = mtcars[1:3, ],
  rowHeaders = TRUE,
  rowHeaderWidth = 200,
  adaptiveHeight = TRUE
)
  • rowHeaders = FALSE omits the row names column:
handsontable(
  data = mtcars[1:3, ],
  rowHeaders = FALSE,
  adaptiveHeight = TRUE
)
  • use a character vector if you want to customize the name of each row:
handsontable(
  data = mtcars[1:3, ],
  rowHeaders = paste0(LETTERS, letters)[1:3],
  adaptiveHeight = TRUE
)

hot_context_menu

with hot_context_menu(), you can configure options for the table’s context menu ie. the menu you see when you right-click on a handsontable.

hot_col

use hot_col() to configure options for columns. this can be a single column or multiple of them.

hot_row

  • config options for rows

use hot_row() to configure options for rows.