Error while executing shiny code from R conference 2018

rstudio

#1

Hi Friends,

I was trying to understand the asynchronous working from JoeChang demo code
https://speakerdeck.com/jcheng5/r-promises

But could not resolve many errors for example “cannot coerce type ‘environment’ to vector of type ‘double’”.

Please help me to run the code to understand Asynchronous working in Shiny

#install.packages("softmaxreg")
library(datasets)
library(softmaxreg)
library(devtools)
library(arulesViz)
library(future)
#library(multiprocess)

library(parallel)
library(compiler)
library(mgcv)

ui <- basicPage(
    h2("Aynchronous training"),
    actionButton("train","Train"),
    verbatimTextOutput("summary"),
    plotOutput("plot")
) 

server <- function(input,output,session) {
     
    data(iris)
    x = iris[,1:4]
    y = iris$Species
    ptm <- proc.time()
    model <- eventReactive(input$train, {
        f <- future(trainModel(x, y, hidden = c(5), funName = 'sigmoid', maxit = 3000,
                   rang = 0.1, type = "class", algorithm = "adagrad", rate = 0.05, threshold = 1e-3, L2=FALSE,batch =50))
    })
output$summary <- renderPrint({
    print(model())
    print(proc.time() - ptm)
})
output$plot <- renderPlot({
    plot(model())
})
}

shinyApp(ui = ui, server = server)

Thanks
Abhishek