【发布时间】:2018-09-26 22:57:58
【问题描述】:
我是一般编码的新手,目前正在为我的应用程序制作 R 闪亮的应用程序。 它的目的是
- 上传csv文件
- 有多个复选框。如果勾选,数据会走相应的脚本。
- 导出新数据
我已经观看了教程,但我目前在反应方面遇到了一些困难。 我也尝试浏览其他问题,但由于我不熟悉编码,我发现很难从他们的示例中挑选出我需要的内容。
我目前完成了正确的导入和导出功能,并为正文编写了脚本。但是,我不确定如何将这个“主体”合并到服务器端。
这是“body”之一,没有考虑到Shiny:
file1 <- file1[ grep("REVERSE", file1[,c(1)], fixed = FALSE, invert = TRUE),]
Ui 在某处
... fileInput('file1'
.... checkboxInput(inputId = "rmDecoy",
label = "Remove Decoy Entry",
value = TRUE
),
.... mainPanel(
tableOutput('contents')
虽然这是我目前写的服务器端,只有导出功能:
server <- function(input, output) {
getData <- reactive({
inFile <- input$file1
if (is.null(input$file1))
return(NULL)
read.csv(inFile$datapath, header=input$header, sep=input$sep,
quote=input$quote)
})
output$contents <- renderTable(
getData()
)
output$downloadData <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
write.csv(getData(), file)
})
}
当我使用output$rmDecoy 时它有点工作,但是当我将它与下载数据功能一起使用时,它就停止了。
因此,我的问题是
- 我的理解是,您并没有尝试直接更改输入。相反,您正在渲染新表、更改它并导出它。我了解 R Shiny 的原理吗?
- 如何将上述脚本合并到服务器中?
感谢您的帮助。
【问题讨论】:
标签: r shiny shiny-server shiny-reactivity