我有一个闪亮的应用程序,经过一些数据处理,我想下载mytable
。非常感谢。
library(shiny)
ui <- navbarPage(
title = 'Benvenuti',
tabPanel('read.me', column(3,
h3("Daily Data Manipulation"),
h3("title1"),
tags$a("Upload data.xlsx")
)),
tabPanel(title = "title2",
sidebarPanel( width = 2, fileInput('file1', 'Choose xlsx file',
accept = c(".xlsx")),
numericInput("ID", "Enter the starting ID number:",
value = 1, min = -Inf, max = Inf),
downloadButton("Download.mytable", "Download mytable")
),
mainPanel(tableOutput(outputId = "mytable"))
) )
server <- function(input, output) {
data.Consenso <- reactive({
inFile <- input$file1
if(!is.null(inFile)) {
readxl::read_excel(inFile$datapath)
#read.csv(inFile$datapath, header = TRUE, stringsAsFactors = FALSE)
}
})
output$mytable <- renderTable({
dat <- data.Consenso()
if(!is.null(dat))
{
dat$Tipo <- 3
dat
}
})
mytable2 <- reactive({mytable})
output$Download.mytable <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
write.csv(mytable2(), file)
})
}
shinyApp(ui = ui, server = server)
错误
Warning: Error in <reactive:mytable2>: object 'mytable' not found
3: runApp
2: print.shiny.appobj
1: <Anonymous>
照片
1条答案
按热度按时间yuvru6vn1#
您使用了
mytable()
,但它在任何地方都没有定义。假设您正在获取原始数据并以某种方式修改内容,您需要这样的东西:我使用的是base-R管道等,这只是一个演示,在允许用户下载新创建的CSV之前,this 是您需要进行任何数据操作的地方。