Hello, I'm asking for help because I'm stuck with a shiny-error when I try to use a reactive to adjust a dose in a non linear mixed effect model (mlxtran code). I think I made a mistake in the way I used the reactive.
Could you help me please ?
Thank you,
I coded as presented below :
library(shiny)
library(ggplot2)
library(mlxR)
ui <-fluidPage(
titlePanel(list(HTML('
'),windowTitle="Modele")
),
wellPanel(navbarPage(title="Simulation",id="NULL",selected="NULL",inverse="FALSE",
tabPanel("Graphiques",tabsetPanel(id="tabs",type="pills",tabPanel("dose"), tabPanel("parametres"),tabPanel("fonctions de sortie"),tabPanel("parametrage")),
fluidRow(
column(3,
br(), br(),
conditionalPanel(condition="input.tabs=='dose'",
sliderInput("amt", "Dose:", value=500, min=250, max=5000, step=50))))))),
column(9, plotOutput("plot1", height="500px")))
server <- function(input, output){
r<-reactive({
out1<-list(name="Cc", time=seq(0,360,by=15))
p<-list(name=c("Cl_pop","V1_pop","Q_pop","V2_pop","p_urine_pop", "omega_V1","omega_Cl","omega_V2","omega_Q","omega_p_urine","b1"),value=c(0.171,12.3,0.528,15.8,0.256,0.589,0.312,0.395,0.122,0.397,0.154))
g<-list(size=10,level="individual")
iv<-list(type=1, time=0,amount=input$amt)
res<-simulx(model='C:/ProgramData/Lixoft/MonolixSuite2019R1/factory/library/pk/new_test_indiv.txt', parameter=p, output=out1, treatment=iv, group=g)
})
t <- reactive({
t1<-paste0("iv<-list(type=1,time=0,amount=",input$amt,")\n")
t2<-paste0("Cc<-list(name='Cc',time=seq(0,360,by=15))\n")
t3<-paste0("p<-list(name=c('Cl_pop','V1_pop','Q_pop','V2_pop','p_urine_pop', 'omega_V1','omega_Cl','omega_V2','omega_Q','omega_p_urine','b1'),value=c(0.171,12.3,0.528,15.8,0.256,0.589,0.312,0.395,0.122,0.397,0.154))\n")
t4<-paste0("g<-list(size=10,level='individual')\n")
t5<-paste0("res<-simulx(model='C:/ProgramData/Lixoft/MonolixSuite2019R1/factory/library/pk/new_test_indiv.txt', parameter=p, output=out1, treatment=iv, group=g)\n\n")
t6<-paste0("qr<-prctilemlx(res$Cc, number=8, level=80)")
txt<-paste0(t1, t2, t3, t4, t5, t6)
return(txt)})
output$plot1 <- renderPlot({
r=r()
qr<-prctilemlx(r, number=8, level=80)
print(qr)})
output$simulx <-renderText(t())
}
shinyApp(ui = ui, server = server)