handsontable(data = iris)
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 amatrix
object.
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 theheight
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
orFALSE
) 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
orFALSE
) 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_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.