I've the following code in source.R which I'm planning to run from shiny. Currently there are hardcoded values in the script (such as 10000, 55, 15, 200 and etc and also some matrix correlation elements below those values):
rnorm2 <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
var1 <- rnorm2(n = 10000, mean = 55 , sd = 15)
var2 <- rnorm2(n = 10000, mean = 200 , sd = 30)
var3 <- rnorm2(n = 10000, mean = 90 , sd = 25)
var4 <- rnorm2(n = 10000, mean = 8 , sd = 3)
R = matrix(cbind(1,.80,.2, .4, .80,1,.7, .6, .2,.7,1,.65, .4, .6, .65, 1),nrow=4)
I've developed a shiny interface that takes input from the user from the numeric input boxes shown in the screenshot of the UI:
Now, I want to connect the input entered from those numeric boxes to the variables in the source.R script that I have, in the place of those hardcoded values (such as 10000, 55, 15, 200 and etc and also the matrix correlation elements below those values).
Actually this is a new approach that I've decided to follow now. Previously I was following a different approach from the answers posted to my question: Unable to figure out how to create and run my user-defined R function in Shiny with input text boxes
I had to choose this new approach because in the previous approach I'm haivng to re-create the entire R code written in the source.R again in the server.R file (you can see the file from the linked question's URL). And also the lines of code are increasing with increasing complexity of the requirement.
So, I thought it best to connect the interface with the already existing R script and run the code and display the output directly in shiny. It sounded smart that way instead of rewriting entire code in server.R file. Also, in the previous approach I've observed the app running very slow down the line when I was implementing various other things.
Please help me with this technique. I'm very new to shiny. I've been working with shiny only for a week now. But I'm really in great need of implementing this new appraoch. It makes things a lot easier and efficient.
