looking for some solutions? You are welcome.

SOLVED: R shiny matrix or table input

Jian:

I am trying to find a way to create a matrix or table as input for user to interact with in R shiny. For example, a matrix like this

sample name             number of tests
350292                  3
...                     ...

Ultimately, I want to automatically generate tabs in the mainPanel for user to input data for these different samples.

One way I find is through matrixInput in the package shinyIncubator, but this is an unofficial package and matrixInput function does not offer an option of column names.

I am wondering if there is any better way to realize this in R shiny?

Update!!! I tried the rhandsontable package, and used the following code.

library(shiny)
library(rhandsontable)

DF <- data.frame(name=c(350292, 360765), run=c(3,2))
colnames(DF) <- c("sample name", "number of tests")

ui <- fluidPage(
  headerPanel("test"),
  mainPanel(rHandsontableOutput("sample"))
)

server <- function(input, output) {
  output$sample <- renderRHandsontable({
    rhandsontable(DF, rowHeaders = NULL) %>%
     hot_col(c("sample name", "number of tests"), format = "0")
  })
}

shinyApp(ui = ui, server = server)

But how to call values in the reactive rhandsontable? Eventually I want to be able to create tabs based on sample name and test number. In this case, it would be 350292_1, 350292_2, 350292_3, 360765_1, 360765_2.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE
Share:

No comments:

Recent