我能';t将csv文件从SHINK传递到RMD。请不要参考其他帖子,因为所有帖子都已通过
用户上载3个数据集->应用程序清理它们->用户下载清理的数据->将清理的数据上载到报告生成器->正在生成报告(Html格式)。清理部件并下载清理后的数据效果良好。一切都在上面工作#报告生成器 服务器.R我能';t将csv文件从SHINK传递到RMD。请不要参考其他帖子,因为所有帖子都已通过,r,shiny,r-markdown,R,Shiny,R Markdown,用户上载3个数据集->应用程序清理它们->用户下载清理的数据->将清理的数据上载到报告生成器->正在生成报告(Html格式)。清理部件并下载清理后的数据效果良好。一切都在上面工作#报告生成器 服务器.R library("shiny") ShinyServer(function(input, output) { data <- reactive({ infile <- input$clin #clin file if(is.null(infile)){ #use has not
library("shiny")
ShinyServer(function(input, output) {
data <- reactive({
infile <- input$clin #clin file
if(is.null(infile)){
#use has not upload it yet
return(NULL)}
table <- read.csv(file=infile$datapath,sep = ",")
return(table)
})
#data for Cree completed
data2 <- reactive({
infile2 <- input$completedCree #Cree completed visits
if(is.null(infile2)){
#use has not upload it yet
return(NULL)}
table2 <- read.csv(file=infile2$datapath,sep = ",")
return(table2)
})
#data for Mul completed
data3 <- reactive({
infile3 <- input$completedMul
if(is.null(infile3)){
#use has not upload it yet
return(NULL)}
table3 <- read.csv(file=infile3$datapath,sep = ",")
return(table3)
})
buttonClicked <- eventReactive(input$clean, {
shinyalert::shinyalert("Warning!", "This process may take up to 3
minutes", type = "info")
clean_data(data(),data2(),data3())
})
output$text <- renderText({
"Click Download! Make sure the file has been successfully downloaded
before closing this window. If not, click Download again."
})
output$downloadData <- downloadHandler(
filename = "cleanedData.csv",
content = function(file) {
write.csv(buttonClicked(),file,row.names = FALSE,na="")
}
)
#REPORT GENERATOR
output$report <- downloadHandler(
filename = "report.html",
content = function(file) {
# Copy the report file to a temporary directory before processing it, in
# case we don't have write permissions to the current working dir (which
# can happen when deployed).
tempReport <- file.path(tempdir(), "report.Rmd")
file.copy("report.Rmd", tempReport, overwrite = TRUE)
# Set up parameters to pass to Rmd document
params <- list(file = input$cleanedFile$datapath)
rmarkdown::render(tempReport, output_file = html_document,params =
params, envir = new.env(parent = globalenv())
)
}
)
})
错误是“找不到参数”而不是在rmarkdown中传递NA,我应该传递一个字符。因此,在RMD文件中,我必须更正以下部分: 参数:
文件:“#而不是NA如果您包含一个简单的示例输入和所需的输出,可用于测试和验证可能的解决方案,则更容易帮助您。代码的图片没有帮助。当你说“它们都不起作用”时,到底是什么问题?您是否收到了某种错误消息或发生了什么事情?请以文本形式发布代码,@MrFlick谢谢您的反馈。这是我第一次使用stackoverflow。如果现在更清楚了,请告诉我
---
title: |
| \vspace{5cm}
output:
html_document:
toc: yes
toc_depth: 2
toc_float: True
number_sections: true
params:
file: NA
---
```{r, echo=FALSE,message=FALSE}
screData = read.csv(file = params$file, sep = ",")
```