我正在使用附加代码根据组生成子表。由于某种原因,仅为每个表呈现数据的最后部分。 如果有人能告诉我出了什么问题,那就太棒了。
BR
library(shiny)
library(shinydashboard)
library(DT)
library(data.table)
tabnames <- LETTERS[1:6]
DT <- data.table(mtcars[1:30,], keep.rownames=TRUE)
DT[, grp:=rep(tabnames, each=trunc(nrow(mtcars)/length(tabnames)))]
ui = dashboardPage(
dashboardHeader(title = "Dynamic DTs"),
dashboardSidebar(),
dashboardBody(
uiOutput("tables"),
p(),
verbatimTextOutput("selectedCells")
)
)
server <- function(input, output, session) {
output$tables <- renderUI({
output_list <- list()
for(i in seq(tabnames)){
output_list[[i]] <- column(4, DT::dataTableOutput(outputId=tabnames[i]))
}
print(fluidRow(output_list))
return(fluidRow(output_list))
})
for(i in seq(tabnames)){
tabname <- tabnames[i]
local({
print(DT[grp %in% tabname, 1:3])
output[[tabname]] <- DT::renderDataTable({
DT[grp %in% tabname, 1:3]
}, selection=list(mode="multiple", target="cell"))
})
}
output$selectedCells <- renderPrint(input$A_cells_selected)
}
shinyApp(ui = ui, server = server)
答案 0 :(得分:1)
好的,找到了一个解决方案:需要将它传递给一个单独的变量:
if(val == middle) Run()
2. if(val > middle && val < top1) Run()
3. if(val >= top1 && val < top2) PickWeapon()
4. if(val >= top2) Jump()
5. if(val < middle && val > bottom1) Run()
6. if(val <= bottom1 && val > bottom2) DropWeapon()
7. if(val <= bottom2) Crawl()