I have written my R script with some functions to do some calculations. On the output of my calculations, I have created plots in shiny(4 tab panels in that as of now, which is using the data specified in my global.R). Now I am trying to automate the process and deliver it to non technical users. So something like, users feed in 2 csv files in web UI and click a button in the web UI, which will then call my r scripts to do the calculations, then my server.R script should build plots on the output of it. Any similar examples? I tried different links, but nothing seems to be relevant.
If I add my R script using source(**.R) and use the functions mentioned in there. Or Do I still have to save output in data folder and specify something in global.R or just use the output of the function in my plot construction?
If I have the fileInput option in first tab in my tabpanels, how can I make stop the user from viewing the other tabs(tabs with graphs) without loading the input csv files and clicking the "Go" button?
Can I do this whole thing in Shiny ? Or better to go for rook or some other framework which calls my r script just for calculations?
Related
I have a .mat file that contains certain data. How would I insert that data and be able to display it using Shiny?
Use the R.matlab package and the readMat() function to get the file into R, after that, you can build a shiny app from scratch the way you normally would.
In my shiny app I am using multiple parametrised variables that depend on a csv configuration file that lists all the IDs needed for the shiny HTML output elements.
In my ui the process is very easy. I do as follows:
htmlOutput(outputId = paste0("Variable",y))
where y is the looping variable over the IDs
The problem is on the server side of the shiny app when i want to render this HTML element. The way how I am currently doing so is using the eval parse method. The biggest drawback of that solution is that it consumes a lot of time (in addition to a higher difficulty in reading the R code). An example of rendering the above object:
eval(parse(text=paste0("output$Variable",y,"<-renderText({return(paste(\"<div style=\\\"text-align: center;\\\">\",",result,",\"</div>\"))})")))
Is there any other more efficient way to render parametrised variable names on the server side of my Shiny App?
I tried to use get and assign functions but neither of them worked.
Thanks for your help!
I have some code that reorganizes some spreadsheets and then creates a shiny from the spreadsheet. All of this code sits in a master script within functions. This way, when I need to run a particular function I just source the master script and run the function.
Is it possible to publish the output onto shinyapps.io without physically pushing the publish button? I just want to be able to run the function and have it publish automatically.
edit 1: is there was a way I could make "appDir" = "some function in my master script"?
edit 2: Fixed the problem to edit 1. Don't put shiny code within a function.
edit 3: Is there a way to call the app.R file and my .csv file in rsconnect if they are in different locations?
I have multiple render functions within the R shiny code performing independent tasks (multiple output plots) on the user uploaded file. I would like all these render functions to start running in parallel when the user uploads the file. How could I do that in R shiny?
You can use reactive with file upload button to store a data, and call it in every renderPlot function :
And you should paste your code what you have done so far on Stack Overflow, it will be more easier to help:
df<-reactive({ read.csv(path) })
# call the csv file with df() rather than df when you use reactive to store it
output$plot1<-renderPlot({plot(df()[,1])})
output$plot2<-renderPlot({plot(df()[,2])})
Something like this
I'm trying to build a webpage displaying a few graphs. I want to use R to build the graphs, and I want these graphs to automatically update themselves periodically. For example, a webpage showing a graph of the stock price of a particular company over time, which refreshes every day with new data.
what is the best way to approach this? Using Rook to run the R-scripts? can I use it along Markdown, for example, to make the html webpage? Or do you suggest something else?
You can make your plots in a R file and write your webpage in markdown in which you call your R objects and plots. Alternatively you can also run the R code directly in the markdown file. With the knit2html function of the knitr package you can create the html page with the desired output. You can find basic examples on the knitr webpage.
You can schedule these file(s) on your own computer or on a server to update the data of the html output every day. If you have a machine that runs on Windows you can use the Windows Task Manager to run the batch file.
EDIT:
Here you can find a worked out example.