我正在構建一個閃亮的應用程序,它可以從用戶獲取輸入值並動態顯示數據框。當我不使用shinydashboard庫時,我能夠成功顯示數據幀。但我有顯示使用dataTableOutput在ui.R和server.RR Shiny:如何使用shinydashboard庫在閃亮的應用程序中顯示數據框
我也試過顯示mtcars據幀,這是不是一個反應數據幀renderDataTable數據幀麻煩,但它也不會被顯示。
這是我在我的server.R文件:
values<- reactiveValues()
values$df<- data.frame()
observeEvent(input$click_counter, {
name<- input$name
gender<- input$gender
college<- input$college
team<- input$team
score<- as.numeric(input$score)
rank<- 0
new_row<- data.frame(rank,name,college,gender,team,score)
values$df<- rbind(values$df, new_row)
values$df<- values$df[order(values$df$score,decreasing=TRUE),]
values$df$rank<- 1:nrow(values$df)
})
output$nText2<- renderDataTable({
datatable(values$df)
}, options = list(orderClasses = TRUE,lengthMenu = c(5, 10, 30), pageLength = 5))
這是我在ui.R文件:
tabItem(tabName = "signup",
fluidRow(
box(textInput("name", "이름"),
selectInput("college", "대학",
choices = list("간호대학", "경영대학",
"공과대학", "농업생명과학대학",
"미술대학", "법과대학",
"사범대학", "사회과학대학",
"수의과대학", "생활과학대학",
"약학대학", "음악대학",
"인문대학", "의과대학",
"자연과학대학", "기타"),
selected = 1),
selectInput("team", "교내 소속축구팀",
choices = list("싸커21", "아르마다",
"에코플러스", "아크로",
"P.O.S", "공대",
"자연대", "관악사",
"농대축구부 휘모리", "지오싸카스",
"새츠", "샥스",
"FC SEES", "Cells United",
"프리템포", "남풍",
"없음")),
textInput("score", "점수"),
actionButton("click_counter","Submit")),
box(DT::dataTableOutput("nText2"))
)
嘗試:'$輸出nText2 < - renderDataTable(值爲$ df,options = list(orderClasses = TRUE,lengthMenu = c(5,10,30),pageLength = 5))in in server.R and'box(dataTableOutput(「ntext2」))'in ui.R – ottlngr
@ottlngr這正是我最初的想法,但它也無法工作... – Oleole