r - R Shiny:从表输入创建和输出新表
问题描述
这是原始问题的延续。
我尝试做的是从输入创建一个新表并将该新表打印为输出。
我也想从输入中提取列来创建其他几个表。
我的代码给出了错误:赋值左侧无效(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)
解决方案
推荐阅读
- android - ConstraintLayout View Gone 保留空间
- ios - SWIFT - 将文件上传到 icloud 文档未完成
- css - 在背景图像中使用线性渐变
- c++ - 将十六进制值设置为 char 变量以进行填充的问题
- php - 输入密码不符合 CSS
- python - 如何使用熊猫将列更改为行?
- apache-spark - 如何在 PySpark 中通过包含文本和数字的制表符和行拆分 rdd 元素
- javascript - 仅捕获字母后跟字母,不包括某些单词 - 正则表达式
- r - 在折线图中显示三个因素
- python - Python Flask Oidc + Keycloak 获取组、属性