如何将通过排序生成的对象馈送到列表,向量或数据框架中?
我正在尝试R Shiny软件包可排序
。我正在尝试将可重复的代码中的bucket_list
生成的元素添加到列表,向量或数据框架中,以准备在我开发此过程时为进一步的数据操作做准备。我不知道下面由buck_list
生成了哪种对象。理想情况下,我需要将数值排名(下面的1和2)划分为一列,然后将池ID(B和A)划入单独的数据帧列中。
如何将这些元素馈送到列表/向量/数据框中?底部的图像更好地说明了。
可重复的代码:
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'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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是在解决I_O昨天评论的解决方案:
Here is working the solution incorporating yesterday's comment from I_O: