From the sales dashboard project I developed using R and shinydashboard, please read it if you haven’t. I created a small command line batch script to run it at the backend. In that project, I use Windows 10 with R package installed in the PC.
It is very simple script to run your finished R script from cmd batch command line. Use your R Studio, create a new text file, then save it as batch file, for example startserverdashboard.bat. Type the following line into your batch file:
"your-R-path-installation-bin\Rscript.exe" \your-R-script-folder\salesdashboard.R
Change your-R-script-folder to your actual folder where you saved your script.
To run the server script, open a terminal/cmd, got to the folder where you stored the script, then just type the batch file from command line:
startserverdashboard.bat
That’s all you have to do. The batch will run the script including web server with port to run the dashboard report. To stop the web server, click Ctrl-C, or just close the command line window.
Access the Dashboard from Mobile Phone
The above approach is simple, and already good enough for the needs. The owner can get sales numbers in chart dashboard as he/she wish. It is secured enough, since the dashboard is only accessible from the POS PC, where only the cashier and the owner can see it.
However, if you want to have easy access to the dashboard, for example by owner’s mobile phone as long as connected in the same network/wifi. This approach can be achieved by opening the IP and the port on the firewall setting. You can search from internet how to do it. You can still secure the dashboard by limiting who can access to the PC on the security setting.
Depends on your network settings, by default, the router on the network will give dynamic IP and the port. You need to change it so you will have static IP and port address to access the report. To do this, R web server need to be set to a specific static IP address and Port. Create new R script from your R Studio, type the following script:
require(shiny)
folder_address = '\\path-to-your-code-folder\\salesdashboard.R'
x <- system("ipconfig", intern=TRUE)
z <- x[grep("IPv4", x)]
ip <- gsub(".*? ([[:digit:]])", "\\1", z)
print(paste0("the Shiny Web application runs on: http://", ip, ":3838/"))
runApp(folder_address, launch.browser=FALSE, port = 3838, host = ip)
Change the path-to-your-code-folder to your R script folder. The port 3838 is default port setting that is used by shiny web server. You can change it as you wish. Don’t forget to allow the port number access in your firewall setting.
Now the owner can access the dashboard report, anywhere using mobile phone as long as he/she is in the cafe, in the same network/wifi.
Access Dashboard anywhere
If there are many shops in different locations you will need cloud solution. The dashboard can be access by the owner from home or from anywhere in the world. The R server is stored in the cloud. There are many R cloud based services available in AWS, Google, Microsoft Azzure, etc.
Source data is generated from each store, and then upload to the database in the cloud. R server then process all the data into dashboard reports. The cost is vary depends on what solution do you use. But nowadays the cost is scalable and adjust automatically accordingly as the growth of your business, means the bigger your business, the more data you will have, means more server resources you will need, at the end will add the cost you have to spend.