The deployment of my choice model is failing due to the above error when I run the code. I am not super sure why and when this has happened previously
library(shiny)
library(idefix)
levels <- c(3,3,3,3)
coding <-c("D","D","D","D")
priors <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
s <- diag(length(priors))
sim <- MASS::mvrnorm(n = 500, mu = priors, Sigma = s)
sim <- list(sim[, 1:1], sim[, 2:9])
alt.cte <- c(0, 0, 1)
d <- CEA(lvls=levels, coding=coding, n.alts=3, n.sets=16, alt.cte=alt.cte,
par.draws=sim, no.choice=FALSE)
design <- d$design
n.sets <- 16
alternatives <- c("Alternative", "Alternative", "Alternative")
attributes <- c("Cost", "Management", "Crops", "Assessment method")
labels <- vector(mode = "list", length(attributes))
labels[[1]] <- c("£300", "£200/ha", "£100/ha") # 3 levels
labels[[2]] <- c("Organic", "Lots of inputs", "Small inputs") # 2 levels
labels[[3]] <- c("Barley", "Oats", "Wheat") # 3 levels
labels[[4]] <- c("Diaries", "Results based payments", "Forms") # 2 levels
code <- c("D", "D", "D", "D")
b.text <- "Please choose the alternative you prefer"
i.text <- "Welcome, here are some instructions: In each question 3 options will be presented, please choose the one that makes the most sense to you.
It is 16 questions long and should take about 5 minutes maximum. Please continue through the survey until you get to a screen saying thank you for taking the survey, good luck!"
e.text <- "Thanks for taking the survey - please follow this link to the next survey.
It will be very similar so please take it as soon as you can. If you would like to get in touch
with me to get some more information about the project I can be contacted at: millicent.v.harding@durham.ac.uk"
ui <- SurveyApp(des = design, n.total = n.sets, alts = alternatives,
atts = attributes, lvl.names = labels, coding = code,
buttons.text = b.text, intro.text = i.text, end.text = e.text, alt.cte = c(0,0,1),
data.dir = NULL)
server <- shinyServer(function(input, output){})
outputDir <- "responses"
saveData <- function(data) {
data <- t(data)
# Create a unique file name
fileName <- sprintf("results.csv", as.integer(Sys.time()), digest::digest(data))
# Write the file to the local system
write.csv(
x = data,
file = file.path(Documents/year_3/DISS/MODELS/R_STUDIO/FINAL, "results"),
row.names = FALSE, quote = TRUE
)
}
shinyApp(ui, server)
The logs then show
2021-03-04T11:24:36.924358+00:00 shinyapps[3721366]: Running on host: 3244eb4f38e2
2021-03-04T11:24:36.929405+00:00 shinyapps[3721366]: Server version: 1.8.6.1
2021-03-04T11:24:36.929422+00:00 shinyapps[3721366]: R version: 4.0.3
2021-03-04T11:24:36.929421+00:00 shinyapps[3721366]: LANG: en_GB.UTF-8
2021-03-04T11:24:36.929468+00:00 shinyapps[3721366]: jsonlite version: 1.7.2
2021-03-04T11:24:36.929423+00:00 shinyapps[3721366]: shiny version: 1.6.0
2021-03-04T11:24:36.929432+00:00 shinyapps[3721366]: rmarkdown version: (none)
2021-03-04T11:24:36.929423+00:00 shinyapps[3721366]: httpuv version: 1.5.5
2021-03-04T11:24:36.929438+00:00 shinyapps[3721366]: knitr version: (none)
2021-03-04T11:24:36.929499+00:00 shinyapps[3721366]: RJSONIO version: (none)
2021-03-04T11:24:36.929660+00:00 shinyapps[3721366]: Using pandoc: /opt/connect/ext/pandoc/2.11
2021-03-04T11:24:37.126060+00:00 shinyapps[3721366]:
2021-03-04T11:24:36.929500+00:00 shinyapps[3721366]: htmltools version: 0.5.1
2021-03-04T11:24:37.122830+00:00 shinyapps[3721366]: Using jsonlite for JSON processing
2021-03-04T11:24:37.126061+00:00 shinyapps[3721366]: Starting R with process ID: '24'
2021-03-04T11:28:38.775016+00:00 shinyapps[3721366]: Error in value[3L] : app.R did not return a shiny.appobj object.
2021-03-04T11:28:38.775018+00:00 shinyapps[3721366]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
2021-03-04T11:28:38.775019+00:00 shinyapps[3721366]: Execution halted
Any help would be much appreciated as I am unsure where exactly the error lies and I would like to understand where exactly I have gone wrong!!