I'm trying out R Shiny package sortable
. I'm trying to feed the elements generated by the bucket_list
in the reproducible code below into either a list, vector, or dataframe, to prepare for further data manipulation as I develop this. I have no idea what sort of object is generated by bucket_list
below. Ideally, I need to strip out the numerical ranking (the 1 and 2 below) into one column and the Pool ID (B and A) into separate dataframe columns.
How can I feed those elements into a list/vector/dataframe? The image at the bottom better illustrates.
Reproducible code:
library(shiny)
library(sortable)
ui <-
fluidPage(
tags$head(tags$style(HTML("
.column_2 {
counter-reset: rank;
}
.column_2 .rank-list-item::before {
counter-increment: rank;
content: counter(rank) '. ';
}
"))),
htmlOutput("rankingForm"),
tableOutput("table1")
)
server <- function(input, output, session) {
output$rankingForm <- renderUI({
fluidRow(
column(tags$b("Pool Ranking"), width = 12,
bucket_list(header = "Drag to the right from the Pool below to rank.",
group_name = "bucket_list_group", orientation = "horizontal",
add_rank_list("Pool:",
labels = c("A","B","C","D","E"),
input_id = "rank_list_1"),
add_rank_list("Pool Ranking:", labels = NULL,
input_id = "rank_list_2"))
)
)
})
output$table1 <- renderTable({ranklist2})
}
shinyApp(ui=ui, server=server)
Here is working the solution incorporating yesterday's comment from I_O:
library(shiny)
library(sortable)
ui <-
fluidPage(
tags$head(tags$style(HTML("
.column_2 {
counter-reset: rank;
}
.column_2 .rank-list-item::before {
counter-increment: rank;
content: counter(rank) '. ';
}
"))),
htmlOutput("rankingForm"),
tableOutput("table1")
)
server <- function(input, output, session) {
output$rankingForm <- renderUI({
fluidRow(
column(tags$b("Pool Ranking"), width = 12,
bucket_list(header = "Drag to the right from the Pool below to rank.",
group_name = "bucket_list_group", orientation = "horizontal",
add_rank_list("Pool:",
labels = c("A","B","C","D","E"),
input_id = "rank_list_1"),
add_rank_list("Pool Ranking:", labels = NULL,
input_id = "rank_list_2"))
)
)
})
output$table1 <- renderTable({input$rank_list_2}) # << solution
}
shinyApp(ui=ui, server=server)