make shiny app standalone with user function - r

I have a shiny app with a bunch of user defined functions and dataframes being passed back and forth between them.
When run from RStudio, it works fine...I can see all the objects in the workspace and everything works just fine. However, when I try to copy and paste the user defined functions in any configuration between the ui.r and server.r files, it complains about not being able to find objects and functions here and there.
What are the best practices for making a shiny app that stands alone, loads external csv files and handles user-defined functions?

Related

Calling global.R in an app.R file on shiny server; unable to call dataframes in for global use

I am developing a shiny app which is an exploratory data analysis tool. At this point, I am trying to optimise so that data is loaded in once but is readily available for all users. I am aware of the scoping materials on this i.e. Scoping I have the code to load the data in for the app within a global.R file like so:-
#global.R file
library(feather)
dataframe1<-read_feather("df1.feather")
dataframe2<-read_feather("df2.feather")
These are the dataframes that I need to call once and make available to all users of the app. However, I am calling the ui and the server code all within app.R and I have a hunch that this could be problematic.
I have tried a few implementations as guided by what I have been able to see on the web but it is obvious that I am not doing something properly. Here are some examples of what I have tried
source('global.R', local = T)
ui<-fluidPage({
#code for ui
})
server<-function(input,output,server){
# code for server
}
shinyApp(ui,server)
Where the outcome is this:-
The second thing I have tried is having the global file called in onStart parameter in the shinyApp(), but I have the same error.
The global file is saved in the GitLab repo that I am using to deploy this app on shiny server. The app.R script Can any one show me how I can correctly call the global.R file, so that the data is loaded in once and made available to all users of the app? Do I need to split the app.R file into a ui.R and a server.R file?

Where to put loaded packages and user defined functions in a shiny app script?

so I'm building a shiny app and when I deploy it to shinyapps.io I get several errors. I suspect the organization of my app script is faulty because I include the "library(package)" commands in the script, as well as all my user defined functions. Should I be placing the loading of packages and my used defined functions in a separate script from the app? and if so, how can I do it?
Thanks so much for any response in advance

Running shiny server app with additional r files

I have 3 files which are needed to my app.
First a general r with functions make some calculations and need to load the ui and server files to run the app.
When I run it on Rstudio it works fine. How is it possible to insert this app to shiny server, meaning that I need first a script and after that run the ui and server files?
Use a global.R file or use source(file, local = FALSE) to read R Code from a file.
For more details check the scoping rules.

in R shiny app File,choose() and dlgsave() Functions are not working properly in shiny.io

I deployed my app in shiny.io. its working some of the java script codings and functions are not working properly. file.choose() & dlgsave() these two functions and Javascript codes are not working remaining all things are working.
save(dlgSave(title = 'Save script to', filters = myfilter[c('R', 'All'), ])$res)
and
p<-source(file.choose())
i added these two function for different purposes, but if i access these two function over the options in my shiny app. Then sever will get disconnected. Even some of the java scripts are also not working. these two functions are working in my local host but its not working shiny.io. is there any solution for this problem???
Thanks in Adavnce.

R shiny concurrent file access

I am using the R shiny package to build a web interface for my executable program. The web interface provides user input and shows output.
On the server background, the R script formats user inputs and saves them to a local input file. Then R calls the system command to run the executable program.
My concern is that if multiple users run the web app at the same time, it is possible that the input file generated by the first user will be overwritten by the second user's input before it is read by the executable program.
One way to solve the conflict is to ask R to create a temporary folder and generate/run the input file under that folder for each user. But I'd like to know whether there is a better or automatic way to resolve this potential conflict with shiny. For example, if use shiny fileInputs, the uploaded files are automatically stored in a temporary folder.
Update
Thanks for the advice.#Symbolix and #Mike Wise
I read the persistent data storage article before but I don't think it is exactly what I wanted. Maybe my understanding is not correct. I end up with creating a temporary folder and run my executable from there.

Resources