Title: | Create a Matrix with Radio Buttons |
---|---|
Description: | An input controller for R Shiny: a matrix with radio buttons, where only one option per row can be selected. |
Authors: | Zsolt Szelepcsényi [aut, cre], Zoltán Szelepcsényi [aut] |
Maintainer: | Zsolt Szelepcsényi <[email protected]> |
License: | GPL-3 |
Version: | 0.2.1 |
Built: | 2024-11-11 03:44:00 UTC |
Source: | https://github.com/szelepke/shinyradiomatrix |
A PFT list, which gives the column names in a taxon-PFT matrix.
A data frame with 31 rows and 2 columns:
Unique identifier for the plant functional types (PFTs).
Name of the PFT.
data(exPftList) str(exPftList)
data(exPftList) str(exPftList)
A taxon list, which gives the row names in a taxon-PFT matrix.
A data frame with 31 rows and 2 columns:
Unique identifier for the variable.
Name of the pollen type or variable, including Linnean and non-Linnean names (Acer saccharum-type, Cerealea, Avena/Triticum).
Default PFT assignment for the variable.
data(exTaxonList) str(exTaxonList)
data(exTaxonList) str(exTaxonList)
Create radioMatrixInput
radioMatrixInput( inputId, rowIDs, rowLLabels, rowRLabels = NULL, choices = NULL, selected = NULL, choiceNames = NULL, choiceValues = NULL, rowIDsName = "ID", labelsWidth = list(NULL, NULL) )
radioMatrixInput( inputId, rowIDs, rowLLabels, rowRLabels = NULL, choices = NULL, selected = NULL, choiceNames = NULL, choiceValues = NULL, rowIDsName = "ID", labelsWidth = list(NULL, NULL) )
inputId |
The input slot that will be used to access the value. |
rowIDs |
character. Vector of row identifiers that will be used to find values that the user has selected. In the output, the component will return a named list of values, each name corresponding to the row id, and the value - to the value user has selected in this row. |
rowLLabels |
character. Vector (or a matrix with one column) of labels that displayed in the leftmost point of each row. The column name of the matrix could be displayed in the header of the assignment matrix. |
rowRLabels |
character. Vector (or a matrix with one column) of labels that displayed in the rightmost point of each row. The column name of the matrix could be displayed in the header of the assignment matrix. Using this argument is optional. But it allows to create Likert scales, potentially with several scales arranged in a matrix. |
choices |
List of values to select from (if elements of the list are named then that name rather than the value is displayed to the user). If this argument is provided, then choiceNames and choiceValues must not be provided, and vice-versa. The values should be strings; other types (such as logicals and numbers) will be coerced to strings. |
selected |
Vector of the initially selected values (if not specified then
defaults to |
choiceNames , choiceValues
|
List of names and values, respectively, that are displayed to the user in the app and correspond to the each choice (for this reason, the objects 'choiceNames' and 'choiceValues' must have the same length). If either of these arguments is provided, then the other must be provided and choices must not be provided. The advantage of using both of these over a named list for choices is that the object 'choiceNames' allows any type of UI object to be passed through (tag objects, icons, HTML code, ...), instead of just simple text. |
rowIDsName |
single character that defines the header of the ID column in the input matrix. |
labelsWidth |
List of two valid values of CSS length unit. Each element
has to be a properly formatted CSS unit of length (e.g., |
HTML markup for radioMatrixInput
library(shiny) library(shinyRadioMatrix) ## Only run examples in interactive R sessions if (interactive()) { data(exTaxonList) data(exPftList) ui <- fluidPage( radioMatrixInput(inputId = "rmi01", rowIDs = head(exTaxonList$Var), rowLLabels = head(as.matrix(subset(exTaxonList, select = "VarName"))), choices = exPftList$ID, selected = head(exTaxonList$DefPFT)), verbatimTextOutput('debug01') ) server <- function(input, output, session) { output$debug01 <- renderPrint({input$rmi01}) } shinyApp(ui, server) } if (interactive()) { ui <- fluidPage( radioMatrixInput(inputId = "rmi02", rowIDs = c("Performance", "Statement A"), rowLLabels = c("Poor", "Agree"), rowRLabels = c("Excellent", "Disagree"), choices = 1:5, selected = rep(3, 2), rowIDsName = "Grade", labelsWidth = list("100px", "100px")), verbatimTextOutput('debug02') ) server <- function(input, output, session) { output$debug02 <- renderPrint({input$rmi02}) } shinyApp(ui, server) }
library(shiny) library(shinyRadioMatrix) ## Only run examples in interactive R sessions if (interactive()) { data(exTaxonList) data(exPftList) ui <- fluidPage( radioMatrixInput(inputId = "rmi01", rowIDs = head(exTaxonList$Var), rowLLabels = head(as.matrix(subset(exTaxonList, select = "VarName"))), choices = exPftList$ID, selected = head(exTaxonList$DefPFT)), verbatimTextOutput('debug01') ) server <- function(input, output, session) { output$debug01 <- renderPrint({input$rmi01}) } shinyApp(ui, server) } if (interactive()) { ui <- fluidPage( radioMatrixInput(inputId = "rmi02", rowIDs = c("Performance", "Statement A"), rowLLabels = c("Poor", "Agree"), rowRLabels = c("Excellent", "Disagree"), choices = 1:5, selected = rep(3, 2), rowIDsName = "Grade", labelsWidth = list("100px", "100px")), verbatimTextOutput('debug02') ) server <- function(input, output, session) { output$debug02 <- renderPrint({input$rmi02}) } shinyApp(ui, server) }