如何将 sortable 生成的对象提供给列表、向量或数据框?
How to feed object generated by sortable into a list, vector, or dataframe?
我正在试用 R Shiny 包 sortable
。我正在尝试将下面可重现代码中 bucket_list
生成的元素提供给列表、向量或数据框,以便在我开发它时为进一步的数据操作做准备。我不知道下面的 bucket_list
生成了什么样的对象。理想情况下,我需要将数字排名(下面的 1 和 2)剥离到一列中,并将池 ID(B 和 A)剥离到单独的数据框列中。
如何将这些元素输入 list/vector/dataframe?底部的图片更好地说明了。
可重现代码:
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)
这是结合昨天来自 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)
我正在试用 R Shiny 包 sortable
。我正在尝试将下面可重现代码中 bucket_list
生成的元素提供给列表、向量或数据框,以便在我开发它时为进一步的数据操作做准备。我不知道下面的 bucket_list
生成了什么样的对象。理想情况下,我需要将数字排名(下面的 1 和 2)剥离到一列中,并将池 ID(B 和 A)剥离到单独的数据框列中。
如何将这些元素输入 list/vector/dataframe?底部的图片更好地说明了。
可重现代码:
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)
这是结合昨天来自 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)