Matrix Input for Shiny

Travis-CI Build Status Coverage Status CRAN_Status_Badge

Matrix Input for Shiny

This package provides an input field to enter matrix conveniently in a shiny application. It supports tabbing and jumping linewise in the matrix, copy-pasting from other spread sheets applications.

Screenshot Simple Matrix


From CRAN:


From GitHub:

if (require("devtools")) install_github("INWTlab/shiny-matrix")



The input field is generated by the function matrixInput

matrixInput <- function(inputId,
                        value = matrix("", 1, 1),
                        inputClass = "",
                        rows = list(),
                        cols = list(),
                        class = "character"
                        pagination = FALSE,
                        lazy = FALSE){

You can define parameters as follows:

Parameter Description
inputId id of html element
value matrix
inputClass class of html element (Class matrix-input is added automatically)
rows list of parameters (see below)
cols list of parameters (see below)
class class of resulting matrix (numeric and character) is supported
pagination Should the matrix be paginated (10 rows per page)
lazy Lazy update data on server

Parameter rows / cols take a list of arguments. The following is supported

Parameter Description
n number of rows (is calculated from value per default)
names show row/colnames (names are taken from value)
editableNames should row/colnames be editable?
extend should rows/cols be automatically be added if table is filled to the last row / column?
delta how many blank rows/cols should be added
multiheader Display multiheader - currently only header spanning two columns are supported

Call the matrixInput function in your UI generating, e.g. ui.R

## numeric matrix
matrixInput("matrix1", class = "numeric")

## editable rownames
  rows = list(
    names = TRUE,
    editableNames = TRUE),
  data = matrix(letters[1:12], 3, 4)

Get value

You can access the value from the matrix input using input$inputId in your server function. The result will always be a matrix of the class defined in matrixInput.

Update Input Field

You can update the input field using updateMatrixInput

updateMatrixInput(session, inputId, value = NULL)

value is the data object. In the future there should be also support to update the other parameters.

Example Apps

You find the code for the example app in inst/appXXX.

Basic functionality

Use the matrix on the left to input values, matrix on the right displays the result.



Update Matrix Input from R


Editable row and column names


Extend Matrix Automatically


Custom Column Header


Delete Rows and Columns


Lazy Update of server values