我正在制作一个小型应用程序,用户可以在其中输入数据。我可以使该应用程序运行一行,但是试图对源数据的任何数量的行进行概括。源数据是两列csv,第一列中有说明,第二列中有美元金额。
执行此操作时,出现错误:Reading objects from shinyoutput object not allowed
。我已经阅读了有关此错误消息的所有其他问题,但无法弄清楚问题出在哪里。我认为问题是反应性环境的结果,但是我无法解决这个问题。任何帮助将不胜感激。请让我知道是否可以解决问题。
library(shiny)
library(shinythemes)
thing <- data.frame("Description" = c("Description1","Description2","Description3"), FY2017.2018 = c(1500,2000,2500))
server <- function(input, output, i) {
output$A[i] <- renderText({input$U[i]})
output$B[i] <- renderText({input$V[i]})
output$C[i] <- renderText({input$W[i]})
output$D[i] <- renderText({input$X[i]})
output$E[i] <- renderText({input$Y[i]})
output$K[i] <- renderText({input$Z[i]})
output$G[i] <- renderText({input$U1+input$U2+input$U3+input$U4+input$U5+input$U6})
}
v1 <- lapply(1:nrow(thing), function(i){
fluidRow(column(1,thing$Description[i]),
column(1, paste0("$",round(thing$FY2017.2018[i]))),
column(1,sliderInput(inputId = paste0("U",i),label = NULL,value = 0,min=0,max = 100, step=5)),
column(1,sliderInput(inputId = paste0("V",i),label = NULL,value = 0,min=0,max = 100, step=5)),
column(1,sliderInput(inputId = paste0("W",i),label = NULL,value = 0,min=0,max = 100, step=5)),
column(1,sliderInput(inputId = paste0("X",i),label = NULL,value = 0,min=0,max = 100, step=5)),
column(1,sliderInput(inputId = paste0("Y",i),label = NULL,value = 0,min=0,max = 100, step=5)),
column(1,sliderInput(inputId = paste0("Z",i),label = NULL,value = 0,min=0,max = 100, step=5))
)
})
v2 <- lapply(1:nrow(thing),function(i){
fluidRow(column(1, ""),
column(1, ""),
column(1, textOutput(paste0("A",i))),
column(1, textOutput(paste0("B",i))),
column(1, textOutput(paste0("C",i))),
column(1, textOutput(paste0("D",i))),
column(1, textOutput(paste0("E",i))),
column(1, textOutput(paste0("K",i))),
column(1, strong(textOutput(paste0("G",i))))
)
})
v3 <- c(rbind(v1,v2))
ui <- fluidPage(theme = shinytheme("simplex"),
fluidRow(column(1,"Description"),
column(1,"Current Expense"),
column(1,"Cost Type 1"),
column(1,"Cost Type 2"),
column(1,"Cost Type 3"),
column(1,"Cost Type 4"),
column(1,"Cost Type 5"),
column(1,"Cost Type 6"),
column(1,strong("Total"))),
v3
)
shinyApp(ui = ui, server=server)