Specificaly, I want shiny input values to feed into drop-down menus on Rhandsontable. Generally, I often want to use shiny input to fill out cells and columns in a table, in addition to letting the user edit the rhandsontable.
Here is a small example app that highlights my intentions:
library(rhandsontable)
library(shiny)
non_reactive_choices <- c('choice1', 'choice2', 'choice3', 'choice4', 'choice5', 'choice6', 'choice7', 'choice8')
DF <- data.frame(col_1 = 'original value',
col_2 = 'original value',
col_3 = 'original value',
col_4 = 'original value')
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput('c1', label='first choice', choices = non_reactive_choices, selected = 'choice1'),
selectInput('c2', label='second choice', choices = non_reactive_choices, selected = 'choice2'),
selectInput('c3', label='third choice', choices = non_reactive_choices, selected = 'choice1'),
selectInput('c4', label='fourth choice', choices = non_reactive_choices, selected = 'choice2')
),
mainPanel(
HTML('<br>'),
HTML('<h3> The first table has pulldown of non-reactive values: it works</h3>'),
rHandsontableOutput('hotable1'),
HTML('<h3> The second tables pulldowns point to reactive values: it doesnt work</h3>'),
rHandsontableOutput('hotable2'))
)
)
server <- function(input, output, session) {
output$hotable1 <- renderRHandsontable({
rhandsontable(DF, width = 600, height = 200) %>%
hot_col(col = 'col_1', type = "dropdown", source = non_reactive_choices) %>%
hot_col(col = 'col_2', type = "dropdown", source = non_reactive_choices) %>%
hot_col(col = 'col_3', type = "dropdown", source = non_reactive_choices) %>%
hot_col(col = 'col_4', type = "dropdown", source = non_reactive_choices)
})
#here I combine the inputs and use them as the only choices for my dataframe dropdown columns
combined_inputs <- reactive({
c(input$c1, input$c2, input$c3, input$c4)
})
output$hotable2 <- renderRHandsontable({
rhandsontable(DF, width = 600, height = 200) %>%
hot_col(col = 'col_2', type = "dropdown", source = combined_inputs() ) %>%
hot_col(col = 'col_3', type = "dropdown", source = combined_inputs() ) %>%
hot_col(col = 'col_4', type = "dropdown", source = combined_inputs() )
})
}
shinyApp(ui, server)
I am writing experimental procedures in Rmarkdown using shiny runtime- often the SOP includes making a 96-well tray for biochemistry experiments. I need to build 96-well tray for the user to use, based on their input (what samples they are using, how many samples they have, what assay they want, etc), and then allow them to record values into the table. This serves both to help the user set up the experiment, and for the user to report back the results.
Overall, I want to put user input/reactive values into rhandsontable - not just get the input from the rhandsontable.