在Shiny中上传许多文件 [英] Uploading many files in Shiny
本文介绍了在Shiny中上传许多文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个可按主题/主题组织和可视化许多PDF文档的应用程序.我可以上传和阅读一个PDF,但是很难阅读多个PDF文档.
I am developing an app that helps to organize and visualize many PDF documents by topic/theme. I can upload and read a single PDF but I have difficulty in reading multiple PDF documents.
对于单个PDF文档:
ui.R
---
fileInput('file1', 'Choose PDF File', accept=c('.pdf'))
---
server.R
--------
library(pdftools)
-------
mypdf<-reactive({
inFile <- input$file1
if (is.null(inFile)){
return(NULL)
}else{
pdf_text(inFile$datapath)
}
})
要上传多个PDF文件,我必须在代码的ui.R部分中使用multiple = TRUE,但是如何读取所有上传的文件?
To upload multiple PDF files, I have to use multiple = TRUE in the ui.R portion of the code, but how can I read in all the uploaded files?
推荐答案
可以在这样的for循环中读取上载的文件
The uploaded files can be read in a for loop like this
for(i in 1:length(input$files[,1])){
lst[[i]] <- read.csv(input$files[[i, 'datapath']])
}
这是CSV文件的示例,但您可以对pdf文件进行同样的操作.
This is an example for CSV files but you can do the same for pdf files.
这篇关于在Shiny中上传许多文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文