MyNixOS website logo
Description

Shiny Matrix Input Field.

Implements a custom matrix input field.

Matrix Input for Shiny

R-CMD-check Coverage Status CRAN status

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.

Screenshot Simple Matrix

Installation

From CRAN:

install.packages("shinyMatrix")

From GitHub:

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

Usage

UI

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
matrixInput("matrix2",
  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

  • Fixed matrix width
  • Editable matrix content
  • No column and rownames

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

library(shinyMatrix)

startApplication("app")

Update Matrix Input from R

  • Generate a random matrix within the shiny server function by clicking on "Update Matrix"
  • The matrixInput field gets updated with updateMatrixInput from R
startApplication("appUpdate")

Editable row and column names

  • Edit row and column names by clicking on the cell
  • The result will be shown on the right
startApplication("appRownames")

Uneditable cells

  • Make table cells uneditable
  • No clicking into cells, no changing values
startApplication("appUneditableCells")

Extend Matrix Automatically

  • If matrix is full (last row and columns contain values) rows and columns are added automatically
startApplication("appExtend")

Custom Column Header

  • Replace default header with a multiheader
  • Automatically add 2 columns if matrix is full
startApplication("appDoubleHeader")

Delete Rows and Columns

  • add a button to delete rows and columns. This also works for multiheader.
startApplication("appDelete")

Lazy Update of server values

  • Only update data on server when no input field is visible
startApplication("appLazy")
Metadata

Version

0.8.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows