Need ui.R to get file / directory input path as string

I have a fair sized R-sized program that processes all text files (executed by LSA) in a given directory. It works, but it's not exactly user-friendly and I'm trying to use Shiny to fix it. The problem is simply to provide users with a good way to select a directory and get the path to it; then I can walk the path to my R program. Something like this:

fileInput("corpDir", label = "Choose the directory containing the corpus.")

      

... then, in Server.R, get the path through the $ corpDir input and pass it to the R program. But the fileInput widget does too much (I don't want to load the file, just want to get its path) and too little (it returns the filename, but not the way). And R file.choose will be fine - well, it would be better if it allowed directory selection, but if users select a file in a directory, that's ok - but I can't see how I can use file.choose from Brilliant interface. I went through the RStudio site, including my gallery of examples, and tried to find an answer on the google group and here. I haven't found anything like this. TIA for any suggestions.

+3


source to share


1 answer


The shinyFiles package can do it!

just install the package and run shinyFilesExample () to see how it works.



(NB: it only works if your shiny app is running locally, you can look at https://github.com/jcolomb/Viewer-file-concatenator and its readme for an example)

+3


source







All Articles