So I'm a bit new to Shiny, but cannot for the life of me, figure out how to get the slider input values organized into a named list. Right now, I have a UI set up that allows for 11 inputs.
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Quorom Sensing Model"),
sidebarPanel(
sliderInput("n", "Hill Coefficient:",
min=0, max=10, value=2, step=0.5),
sliderInput("K", "Max Contribution to lacI transcription:",
min=0, max=50, value=20, step=1),
sliderInput("k0_AI", "Initial Synthesis Rate of AI:",
min=0, max=5, value=3.5, step=0.1),
sliderInput("k1_AI", "Repressor dependent rate of synthesis of AI:",
min=0, max=1, value=.033, step=0.001),
sliderInput("eta", "diffusion rate of AI across cell membrane:",
min=0, max=5, value=.7, step=0.1),
sliderInput("k_deg", "extracellular AI degredation Rate:",
min=0, max=1, value=.525, step=0.001),
sliderInput("k_diff", "extracellular diffusion rate of AI:",
min=0, max=10, value=2.1, step=0.1),
sliderInput("alpha_tetR", "Alpha tetR:",
min=0, max=50, value=24, step=1),
sliderInput("alpha_cI", "Alpha cI:",
min=0, max=50, value=24, step=1),
sliderInput("alpha_lacI", "Alpha lacI:",
min=0, max=50, value=24, step=1),
sliderInput("beta", "Ratio of protein decay to mRNA decay rate:",
min=0, max=10, value=1.05, step=0.05)
),
mainPanel(
plotOutput("timeSeries"),
plotOutput("timeSeries2")
))
)
So these slider inputs need to feed into a named list, where parameters (the named list) = c(n = the value of input$n, K = input$K, etc) so that I can feed the named number list into a function that does the math required to generate the outputs.
Right now, I have the function params, which returns a named list based on the input variables:
params <- function(n = 2,
K=20,
k0_AI=3.5,
k1_AI=0.033,
eta=0.7,
k_deg=0.525,
k_diff=2.1,
alpha_tetR=24,
alpha_cI=24,
alpha_lacI=24,
beta=1.05){
paramlist <- c(n = n,
K = K,
k0_AI = k0_AI,
k1_AI = k1_AI,
eta = eta,
k_deg = k_deg,
k_diff = k_diff,
alpha_tetR = alpha_tetR,
alpha_cI = alpha_cI,
alpha_lacI = alpha_lacI,
beta = beta)
return(paramlist)
}
Which is is called from the server.R and the input variables are set to the input$etc from the sliders?
library(shiny)
library(ggplot2)
library(reshape2)
library(deSolve)
source("params.R")
shinyServer(function(input,output){
parameters = reactive({
params(n = input$n,
K = input$K,
k0_AI = input$k0_AI,
k1_AI= input$k1_AI,
eta = input$eta,
k_deg = input$k_deg,
k_diff = input$k_diff,
alpha_tetR = input$alpha_tetR,
alpha_cI = input$alpha_cI,
alpha_lacI =input$alpha_lacI,
beta = input$beta
)
})
Error in eval(substitute(expr), data, enclos = parent.frame()) : invalid 'envir' argument of type 'closure'
Again, I need the input sliders values to be part of a named list where the name of the slider = the value and the name of the list can be called from a function. How could I do this most easily? Thanks!