Giter Club home page Giter Club logo

shiny-matrix's Introduction

title
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

Installation

From CRAN:

install.packages("shinyMatrix")

From GitHub:

if (require("devtools")) install_github("INWTlab/shinyMatrix")

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",
                        paste = FALSE,
                        copy = 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
paste add pasting functionality
copy add copy functionality

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
createHeader name of javascript function to override default function to create table header. The function needs to have the table element and the data object as argument
updateHeader name of javascript function to override default function to update table header. The function needs to have the table element and the data object as argument
getHeader name of javascript function to override default function to get names from the html table. The function needs to have the table element as argument

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.

library(shinyMatrix)

## Basic Functionality
startApplication("app")

## Copy Pasting
startApplication("appCopy")

## Update Matrix Input from R
startApplication("appUpdate")

## Editable rownames
startApplication("appRownames")

## Extend Matrix Automatically
startApplication("appExtend")

## Custom Column Header 
startApplication("appCustom")

shiny-matrix's People

Contributors

aneudecker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.