Error publishing shiny app: app.R did not return a shiny.appobj object












0















I'm creating an app with a simple ML model, the work flow is as follow:



1) Read a file.
2) Create a model
3) Plot the prediction and variable importance



Localy, the app is working fine:



enter image description here



But when I try to publish the app, I get following error:



Error in value[[3L]](cond) : app.R did not return a shiny.appobj object.
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Ejecución interrumpida


enter image description here



The error is not telling to me, this is the complete code:



library(shiny)
library(readxl)
library(tidyverse)
library(xgboost)
library(caret)
library(iml)


#### UI


ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE)
),
mainPanel(
plotOutput("plot2", click = "plot_brush"),
plotOutput("plot1", click = "plot_brush")
)
)
)

server <- function(input, output) {
# create mydata as a reactiveVal so that it can be edited everywhere
mydata = reactiveVal()
model <- reactiveValues()


# reactive block is changed with an observe that allows mydata to be updated
# on change of data
observe({
req(input$file1, input$header, file.exists(input$file1$datapath))
data = read.csv(input$file1$datapath, header = input$header)
mydata(data)
})


output$contents <- renderTable({
req(mydata())
#mydata()
})


### test
xgb_trcontrol = trainControl(
method = "cv",
number = 5,
allowParallel = TRUE,
verboseIter = FALSE,
returnData = FALSE
)


xgbGrid <- expand.grid(nrounds = c(10,14), # this is n_estimators in the python code above
max_depth = c(10, 15, 20, 25),
colsample_bytree = seq(0.5, 0.9, length.out = 5),
## The values below are default values in the sklearn-api.
eta = 0.1,
gamma=0,
min_child_weight = 1,
subsample = 1
)




observe({

if ('data.frame' %in% class(mydata()) & !'predicted' %in% names(mydata())){
set.seed(0)
xgb_model = train(
select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
trControl = xgb_trcontrol,
tuneGrid = xgbGrid,
method = "xgbTree"
)

predicted = predict(xgb_model, select(mydata(),"LotArea","YrSold"))
data = mydata()
data["predicted"] = predicted
mydata(data)
}


#xgb_model



})

output$plot1 <- renderPlot({
data = mydata()
# this is here to prevent premature triggering of this ggplot.
# otherwise you'll get the "object not found" error
if('predicted' %in% names(data)){
ggplot(mydata(), aes(x=predicted, y=SalePrice)) + geom_point()
}
})

output$plot2 <- renderPlot({
data = mydata()
# this is here to prevent premature triggering of this ggplot.
# otherwise you'll get the "object not found" error
if('predicted' %in% names(data)){

xgb_model = train(
select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
trControl = xgb_trcontrol,
tuneGrid = xgbGrid,
method = "xgbTree"
)

predictor = Predictor$new(xgb_model, data = select(mydata(),"LotArea","YrSold"), y = mydata()["SalePrice"])
shapley = Shapley$new(predictor, x.interest = select(mydata(),"LotArea","YrSold")[1,])
shapley$plot()
}
})


}

shinyApp(ui, server)


And a sample of the input data:



https://drive.google.com/file/d/1R8GA0fW0pOgG8Cpykc8mAThvKOCRCVl0/view?usp=sharing










share|improve this question























  • Have you tried splitting the app into two files ui and server prior to publishing?

    – Philipp R
    Jan 3 at 1:23
















0















I'm creating an app with a simple ML model, the work flow is as follow:



1) Read a file.
2) Create a model
3) Plot the prediction and variable importance



Localy, the app is working fine:



enter image description here



But when I try to publish the app, I get following error:



Error in value[[3L]](cond) : app.R did not return a shiny.appobj object.
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Ejecución interrumpida


enter image description here



The error is not telling to me, this is the complete code:



library(shiny)
library(readxl)
library(tidyverse)
library(xgboost)
library(caret)
library(iml)


#### UI


ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE)
),
mainPanel(
plotOutput("plot2", click = "plot_brush"),
plotOutput("plot1", click = "plot_brush")
)
)
)

server <- function(input, output) {
# create mydata as a reactiveVal so that it can be edited everywhere
mydata = reactiveVal()
model <- reactiveValues()


# reactive block is changed with an observe that allows mydata to be updated
# on change of data
observe({
req(input$file1, input$header, file.exists(input$file1$datapath))
data = read.csv(input$file1$datapath, header = input$header)
mydata(data)
})


output$contents <- renderTable({
req(mydata())
#mydata()
})


### test
xgb_trcontrol = trainControl(
method = "cv",
number = 5,
allowParallel = TRUE,
verboseIter = FALSE,
returnData = FALSE
)


xgbGrid <- expand.grid(nrounds = c(10,14), # this is n_estimators in the python code above
max_depth = c(10, 15, 20, 25),
colsample_bytree = seq(0.5, 0.9, length.out = 5),
## The values below are default values in the sklearn-api.
eta = 0.1,
gamma=0,
min_child_weight = 1,
subsample = 1
)




observe({

if ('data.frame' %in% class(mydata()) & !'predicted' %in% names(mydata())){
set.seed(0)
xgb_model = train(
select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
trControl = xgb_trcontrol,
tuneGrid = xgbGrid,
method = "xgbTree"
)

predicted = predict(xgb_model, select(mydata(),"LotArea","YrSold"))
data = mydata()
data["predicted"] = predicted
mydata(data)
}


#xgb_model



})

output$plot1 <- renderPlot({
data = mydata()
# this is here to prevent premature triggering of this ggplot.
# otherwise you'll get the "object not found" error
if('predicted' %in% names(data)){
ggplot(mydata(), aes(x=predicted, y=SalePrice)) + geom_point()
}
})

output$plot2 <- renderPlot({
data = mydata()
# this is here to prevent premature triggering of this ggplot.
# otherwise you'll get the "object not found" error
if('predicted' %in% names(data)){

xgb_model = train(
select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
trControl = xgb_trcontrol,
tuneGrid = xgbGrid,
method = "xgbTree"
)

predictor = Predictor$new(xgb_model, data = select(mydata(),"LotArea","YrSold"), y = mydata()["SalePrice"])
shapley = Shapley$new(predictor, x.interest = select(mydata(),"LotArea","YrSold")[1,])
shapley$plot()
}
})


}

shinyApp(ui, server)


And a sample of the input data:



https://drive.google.com/file/d/1R8GA0fW0pOgG8Cpykc8mAThvKOCRCVl0/view?usp=sharing










share|improve this question























  • Have you tried splitting the app into two files ui and server prior to publishing?

    – Philipp R
    Jan 3 at 1:23














0












0








0








I'm creating an app with a simple ML model, the work flow is as follow:



1) Read a file.
2) Create a model
3) Plot the prediction and variable importance



Localy, the app is working fine:



enter image description here



But when I try to publish the app, I get following error:



Error in value[[3L]](cond) : app.R did not return a shiny.appobj object.
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Ejecución interrumpida


enter image description here



The error is not telling to me, this is the complete code:



library(shiny)
library(readxl)
library(tidyverse)
library(xgboost)
library(caret)
library(iml)


#### UI


ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE)
),
mainPanel(
plotOutput("plot2", click = "plot_brush"),
plotOutput("plot1", click = "plot_brush")
)
)
)

server <- function(input, output) {
# create mydata as a reactiveVal so that it can be edited everywhere
mydata = reactiveVal()
model <- reactiveValues()


# reactive block is changed with an observe that allows mydata to be updated
# on change of data
observe({
req(input$file1, input$header, file.exists(input$file1$datapath))
data = read.csv(input$file1$datapath, header = input$header)
mydata(data)
})


output$contents <- renderTable({
req(mydata())
#mydata()
})


### test
xgb_trcontrol = trainControl(
method = "cv",
number = 5,
allowParallel = TRUE,
verboseIter = FALSE,
returnData = FALSE
)


xgbGrid <- expand.grid(nrounds = c(10,14), # this is n_estimators in the python code above
max_depth = c(10, 15, 20, 25),
colsample_bytree = seq(0.5, 0.9, length.out = 5),
## The values below are default values in the sklearn-api.
eta = 0.1,
gamma=0,
min_child_weight = 1,
subsample = 1
)




observe({

if ('data.frame' %in% class(mydata()) & !'predicted' %in% names(mydata())){
set.seed(0)
xgb_model = train(
select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
trControl = xgb_trcontrol,
tuneGrid = xgbGrid,
method = "xgbTree"
)

predicted = predict(xgb_model, select(mydata(),"LotArea","YrSold"))
data = mydata()
data["predicted"] = predicted
mydata(data)
}


#xgb_model



})

output$plot1 <- renderPlot({
data = mydata()
# this is here to prevent premature triggering of this ggplot.
# otherwise you'll get the "object not found" error
if('predicted' %in% names(data)){
ggplot(mydata(), aes(x=predicted, y=SalePrice)) + geom_point()
}
})

output$plot2 <- renderPlot({
data = mydata()
# this is here to prevent premature triggering of this ggplot.
# otherwise you'll get the "object not found" error
if('predicted' %in% names(data)){

xgb_model = train(
select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
trControl = xgb_trcontrol,
tuneGrid = xgbGrid,
method = "xgbTree"
)

predictor = Predictor$new(xgb_model, data = select(mydata(),"LotArea","YrSold"), y = mydata()["SalePrice"])
shapley = Shapley$new(predictor, x.interest = select(mydata(),"LotArea","YrSold")[1,])
shapley$plot()
}
})


}

shinyApp(ui, server)


And a sample of the input data:



https://drive.google.com/file/d/1R8GA0fW0pOgG8Cpykc8mAThvKOCRCVl0/view?usp=sharing










share|improve this question














I'm creating an app with a simple ML model, the work flow is as follow:



1) Read a file.
2) Create a model
3) Plot the prediction and variable importance



Localy, the app is working fine:



enter image description here



But when I try to publish the app, I get following error:



Error in value[[3L]](cond) : app.R did not return a shiny.appobj object.
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Ejecución interrumpida


enter image description here



The error is not telling to me, this is the complete code:



library(shiny)
library(readxl)
library(tidyverse)
library(xgboost)
library(caret)
library(iml)


#### UI


ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE)
),
mainPanel(
plotOutput("plot2", click = "plot_brush"),
plotOutput("plot1", click = "plot_brush")
)
)
)

server <- function(input, output) {
# create mydata as a reactiveVal so that it can be edited everywhere
mydata = reactiveVal()
model <- reactiveValues()


# reactive block is changed with an observe that allows mydata to be updated
# on change of data
observe({
req(input$file1, input$header, file.exists(input$file1$datapath))
data = read.csv(input$file1$datapath, header = input$header)
mydata(data)
})


output$contents <- renderTable({
req(mydata())
#mydata()
})


### test
xgb_trcontrol = trainControl(
method = "cv",
number = 5,
allowParallel = TRUE,
verboseIter = FALSE,
returnData = FALSE
)


xgbGrid <- expand.grid(nrounds = c(10,14), # this is n_estimators in the python code above
max_depth = c(10, 15, 20, 25),
colsample_bytree = seq(0.5, 0.9, length.out = 5),
## The values below are default values in the sklearn-api.
eta = 0.1,
gamma=0,
min_child_weight = 1,
subsample = 1
)




observe({

if ('data.frame' %in% class(mydata()) & !'predicted' %in% names(mydata())){
set.seed(0)
xgb_model = train(
select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
trControl = xgb_trcontrol,
tuneGrid = xgbGrid,
method = "xgbTree"
)

predicted = predict(xgb_model, select(mydata(),"LotArea","YrSold"))
data = mydata()
data["predicted"] = predicted
mydata(data)
}


#xgb_model



})

output$plot1 <- renderPlot({
data = mydata()
# this is here to prevent premature triggering of this ggplot.
# otherwise you'll get the "object not found" error
if('predicted' %in% names(data)){
ggplot(mydata(), aes(x=predicted, y=SalePrice)) + geom_point()
}
})

output$plot2 <- renderPlot({
data = mydata()
# this is here to prevent premature triggering of this ggplot.
# otherwise you'll get the "object not found" error
if('predicted' %in% names(data)){

xgb_model = train(
select(mydata(),"LotArea","YrSold"), as.vector(t(mydata()["SalePrice"])),
trControl = xgb_trcontrol,
tuneGrid = xgbGrid,
method = "xgbTree"
)

predictor = Predictor$new(xgb_model, data = select(mydata(),"LotArea","YrSold"), y = mydata()["SalePrice"])
shapley = Shapley$new(predictor, x.interest = select(mydata(),"LotArea","YrSold")[1,])
shapley$plot()
}
})


}

shinyApp(ui, server)


And a sample of the input data:



https://drive.google.com/file/d/1R8GA0fW0pOgG8Cpykc8mAThvKOCRCVl0/view?usp=sharing







r shiny






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 0:47









Luis Ramon Ramirez RodriguezLuis Ramon Ramirez Rodriguez

1,51173364




1,51173364













  • Have you tried splitting the app into two files ui and server prior to publishing?

    – Philipp R
    Jan 3 at 1:23



















  • Have you tried splitting the app into two files ui and server prior to publishing?

    – Philipp R
    Jan 3 at 1:23

















Have you tried splitting the app into two files ui and server prior to publishing?

– Philipp R
Jan 3 at 1:23





Have you tried splitting the app into two files ui and server prior to publishing?

– Philipp R
Jan 3 at 1:23












1 Answer
1






active

oldest

votes


















1














and it worked. Here the app on my shinyapp.io account. Only took a while to upload and to run.



Maybe you'll have to check the applications version. Here's the packages versions I have. I'm on R version 3.5.2 (2018-12-20) and RStudio 1.1.463.



shiny app upload






share|improve this answer
























  • I updated the R version but still is not working. The issue seems to be related with the libraries (iml) and (caret)

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:12











  • Does other shiny apps run correctly on your shinyapp.io account?

    – alessio
    Jan 4 at 18:16











  • Yes, testtvn.shinyapps.io/house I have tried few others as well. I created A new question with mode details here: stackoverflow.com/questions/54044245/…

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:26












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015027%2ferror-publishing-shiny-app-app-r-did-not-return-a-shiny-appobj-object%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














and it worked. Here the app on my shinyapp.io account. Only took a while to upload and to run.



Maybe you'll have to check the applications version. Here's the packages versions I have. I'm on R version 3.5.2 (2018-12-20) and RStudio 1.1.463.



shiny app upload






share|improve this answer
























  • I updated the R version but still is not working. The issue seems to be related with the libraries (iml) and (caret)

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:12











  • Does other shiny apps run correctly on your shinyapp.io account?

    – alessio
    Jan 4 at 18:16











  • Yes, testtvn.shinyapps.io/house I have tried few others as well. I created A new question with mode details here: stackoverflow.com/questions/54044245/…

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:26
















1














and it worked. Here the app on my shinyapp.io account. Only took a while to upload and to run.



Maybe you'll have to check the applications version. Here's the packages versions I have. I'm on R version 3.5.2 (2018-12-20) and RStudio 1.1.463.



shiny app upload






share|improve this answer
























  • I updated the R version but still is not working. The issue seems to be related with the libraries (iml) and (caret)

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:12











  • Does other shiny apps run correctly on your shinyapp.io account?

    – alessio
    Jan 4 at 18:16











  • Yes, testtvn.shinyapps.io/house I have tried few others as well. I created A new question with mode details here: stackoverflow.com/questions/54044245/…

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:26














1












1








1







and it worked. Here the app on my shinyapp.io account. Only took a while to upload and to run.



Maybe you'll have to check the applications version. Here's the packages versions I have. I'm on R version 3.5.2 (2018-12-20) and RStudio 1.1.463.



shiny app upload






share|improve this answer













and it worked. Here the app on my shinyapp.io account. Only took a while to upload and to run.



Maybe you'll have to check the applications version. Here's the packages versions I have. I'm on R version 3.5.2 (2018-12-20) and RStudio 1.1.463.



shiny app upload







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 2:03









alessioalessio

37417




37417













  • I updated the R version but still is not working. The issue seems to be related with the libraries (iml) and (caret)

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:12











  • Does other shiny apps run correctly on your shinyapp.io account?

    – alessio
    Jan 4 at 18:16











  • Yes, testtvn.shinyapps.io/house I have tried few others as well. I created A new question with mode details here: stackoverflow.com/questions/54044245/…

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:26



















  • I updated the R version but still is not working. The issue seems to be related with the libraries (iml) and (caret)

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:12











  • Does other shiny apps run correctly on your shinyapp.io account?

    – alessio
    Jan 4 at 18:16











  • Yes, testtvn.shinyapps.io/house I have tried few others as well. I created A new question with mode details here: stackoverflow.com/questions/54044245/…

    – Luis Ramon Ramirez Rodriguez
    Jan 4 at 18:26

















I updated the R version but still is not working. The issue seems to be related with the libraries (iml) and (caret)

– Luis Ramon Ramirez Rodriguez
Jan 4 at 18:12





I updated the R version but still is not working. The issue seems to be related with the libraries (iml) and (caret)

– Luis Ramon Ramirez Rodriguez
Jan 4 at 18:12













Does other shiny apps run correctly on your shinyapp.io account?

– alessio
Jan 4 at 18:16





Does other shiny apps run correctly on your shinyapp.io account?

– alessio
Jan 4 at 18:16













Yes, testtvn.shinyapps.io/house I have tried few others as well. I created A new question with mode details here: stackoverflow.com/questions/54044245/…

– Luis Ramon Ramirez Rodriguez
Jan 4 at 18:26





Yes, testtvn.shinyapps.io/house I have tried few others as well. I created A new question with mode details here: stackoverflow.com/questions/54044245/…

– Luis Ramon Ramirez Rodriguez
Jan 4 at 18:26




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54015027%2ferror-publishing-shiny-app-app-r-did-not-return-a-shiny-appobj-object%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

'app-layout' is not a known element: how to share Component with different Modules

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

WPF add header to Image with URL pettitions [duplicate]