0

我有一个shiny托管在服务器上的应用程序,其部分功能是读取本地文件。我意识到包中有一个非常有用的fileIput功能shiny——我可能会使用它——但现在我想了解如何使用文件路径。我面临的问题如下:

我正在使用该tm软件包,它允许用户从目录(使用DirSource("filePath"))或使用单个文件(使用VectorSource("filePath"))读取文本文件。

initialCorpus<- reactive({
            if(input$confirm==0)
            return()
            isolate({
                if(input$corpusType=="dir"){
                    myPath<- input$filePath
                    myCorpus<- Corpus(DirSource(myPath))
                    myCorpus
                    }
                else if(input$corpusType=="vector"){
                    myPath<- input$filePath
                    myFile<- scan(file=myPath,what="character",n=-1, sep="\n")
                    myCorpus<- Corpus(VectorSource(myFile))
                    myCorpus
                    } 
...

当我在shiny本地使用我的应用程序时,相同的功能可以正常工作并读取文本文件。但是,当我将我的应用程序上传到shinyapp,然后尝试上传本地文件时,我无法读取文件。

那么,为什么使用文件路径时,shinyApp 无法读取本地文件呢?这可能是一个基本问题,但我想学习。

提前致谢。

PS。如果需要,我很乐意链接到我的应用程序,只是我想在我的应用程序正常运行时显示它。

4

1 回答 1

1

我认为您可以通过隔离您获取文件的部分来解决您的问题:isolate({DirSource("filePath")})

于 2014-02-21T13:37:56.133 回答