Flexible upload data to Shiny-server
There is a function called fileInput comes with Shiny-server, which can upload data to server. In this post, I would like to share my experience of uploading different kind of data (.txt, .csv, .xls, .xlsx, etc.) to Shiny-server.
The idea of flexible uploading data is: using File Selection Dialog to determine the format and location of target document, create different uploading control panel for corresponding format, then upload data using corresponding R package and command. Due to there could be a great number of arguments for an uploading function, e.g.
read.table has more than 20 arguments, I included only the most frequently used arguments, such as header, sep, etc. and take the rest as a character string, so users can type the code they needed themselves.
Open the above application in a new tab.
The flexibility of arguments input was achieved through executing a string as a command:
eval(parse(text = expr))
where expr is a string of command, e.g. ‘read.table(file, header = TRUE)’. The function
parse was suggested to be carefully used by Thomas Lumley, however, I don’t know why and I have no alternative choice.
require(fortunes) Loading required package: fortunes fortune(106) If the answer is parse() you should usually rethink the question. -- Thomas Lumley R-help (February 2005)