How can I read the input file into brilliant?
You have several options. I assume you know how to read a file in R using read.csv
or something similar.
You can put input read.csv
in one of three places:
1) Globlal.r: If you have a file global.r
, you can use read.csv
there and the data will be directly available to functions ui
and server
, Usually you don't need to do this, but this is an option.
For the next two parameters, the data will be available directly to the party server
, but must be passed to the party ui
through one of the functions render
.
2) Server.r, but NOT in shinyServer: In this case, it read.csv
is in the file server.r
, but outside the function shinyServer()
. The file will be read in one time per session and will not change. This is the usual place to read data.
3) Server.r and shinyServer: In this case it read.csv
is part of the function shinySever()
. This is a good place to read data if you want some degree of reactivity involved. For example, if a user chooses what data to enter, or if the data file is constantly updated (perhaps stock prices) and you want to periodically check the data file for updates while the user is logged on.
Note. You also need to consider where the data is stored. You can put it in a subdirectory of your application directory and then read it using a relative (not absolute) path. This is useful if you are testing your application on your desktop but are going to deploy it elsewhere and do not want to rewrite your code to take into account the new directory structure.
source to share