Error incorrect number of dimensions - reactive - shiny

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)

You are more likely to get useful help if you can turn your app into a reproducible example that can easily be run by others. Currently your app contains the path "C:/ProgramData/Lixoft/MonolixSuite2019R1/factory/library/pk/new_test_indiv.txt", which is unlikely to work on my computer.

Dear Hadley,
Thank you for your answer,

Actually the model code is :

[LONGITUDINAL]
input = {Cl, V1, Q, V2, p_urine, b1}
PK:
compartment(cmt=1, volume=V1, amount=Ac, concentration=Cc)
k_urine = p_urine*Cl/V1
k_non_urine = (1-p_urine)*Cl/V1
k12 = Q/V1
k21 = Q/V2
Cc=Ac/V1
DEFINITION:
y={distribution=normal, prediction=Cc,sd=b1}
[INDIVIDUAL]
input={Cl_pop, omega_Cl, V1_pop, omega_V1, Q_pop, omega_Q, V2_pop, omega_V2, p_urine_pop, omega_p_urine}
DEFINITION:
Cl = {distribution=lognormal, prediction=Cl_pop, sd=omega_Cl}
V1 = {distribution=lognormal, prediction=V1_pop,sd=omega_V1}
Q= {distribution=lognormal, prediction=Q_pop,sd=omega_Q}
V2 = {distribution=lognormal, prediction=V2_pop,sd=omega_V2}
p_urine= {distribution=lognormal, prediction=p_urine_pop,sd=omega_p_urine}

I think we are having a communication problem, because that is still not a reproducible example; you have not provided code that I can easily run on my computer. If you can do that (which will typically involve simplifying your app down to the core of the problem), you are much more likely to get help.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.