这是Original Question的延续。
我想做的是从输入创建一个新表,并将该新表打印为输出。
我也想从输入中提取列以创建其他几个表。
我的代码给出一个错误:分配的左侧无效(NULL):
ui <- fluidPage(
headerPanel("title"),
sidebarLayout(
sidebarPanel(
h4("header"),
tags$hr(),
fileInput("file3", "description",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv",".txt")),
tags$hr(),
width = 6
),
mainPanel(
tableOutput("contents3"),
width = 6
)
)
)
server <- function(input, output) {
# input table:
implop <- eventReactive(input$file3,{
read.csv(input$file3$datapath,
sep = input$sep)
})
# create new table:
ip.lzb <- reactive ({ data.frame(cf=rep(0,21))
ip.lzb()[11,] <- sum(implop()[ 1,2])
ip.lzb()[12,] <- sum(implop()[ 2,2])
ip.lzb()[13,] <- sum(implop()[ 3,2])
ip.lzb()[14,] <- sum(implop()[ 4,2])
ip.lzb()[15,] <- sum(implop()[ 5,2])
ip.lzb()[16,] <- sum(implop()[ 6,2])
ip.lzb()[17,] <- sum(implop()[7:9,2])
ip.lzb()[18,] <- sum(implop()[10:12,2])
ip.lzb()[19,] <- sum(implop()[13:24,2])
ip.lzb()[20,] <- sum(implop()[25:60,2])
ip.lzb()[21,] <- sum(implop()[61:120,2])
rownames(ip.lzb()) <- rnames # predefined
ip.lzb()[21,] <- ip.lzb()[21,] - sum(ip.lzb()[1:21,])
})
# return new table:
output$contents3 <- renderTable({
ip.lzb()
})
}
shinyApp(ui, server)