Search code examples
rshinyshinyappscatboost

deploy catboost model shinyapps.io


I have a shiny app that I'm trying to deploy on the https://shinyapps.io page, however the app uses the catboost package. Which can be installed in R as indicated in https://catboost.ai/en/docs/installation/r-installation-binary-installation

install.packages('devtools')
devtools::install_url('https://github.com/catboost/catboost/releases/download/v1.1.1/catboost-R-Windows-1.1.1.tgz', INSTALL_opts = c("--no-multiarch"))

While in linux it is as follows:

devtools::install_url('https://github.com/catboost/catboost/releases/download/v1.1.1/catboost-R-Linux-1.1.1.tgz', INSTALL_opts = c("--no-multiarch"))

Example shinyapp

library(shiny)
library(catboost)

ui <- fluidPage(
  actionButton("go", "Go"),
  numericInput("n", "n", 50),
  plotOutput("plot")
)

server <- function(input, output) {
  randomVals <- eventReactive(input$go, {runif(input$n)})
  output$plot <- renderPlot({hist(randomVals())})
}

shinyApp(ui, server)

image of the error when trying to deploy

enter image description here


Solution

  • I agree with @IRTFM that the devtools::install_github is needed, or even better its source the remotes::install_github. But it is not so apparent that you must use the subdir option.

    When you use the remotes::install_github, additional Remotes/Github fields are added to the package DESCRIPTION file. Thus later, the packrat or renv can handle such dependencies properly.

    Please validate the additional Remotes/Github fields.

    # remotes::install_github('catboost/catboost', ref = "v1.1.1", subdir = 'catboost/R-package', INSTALL_opts = c("--no-multiarch"))
    packageDescription("catboost")
    #> Package: catboost
    #> Title: Gradient Boosting on Decision Trees
    #> Version: 1.1.1
    #> RoxygenNote: 7.1.2
    #> Imports: jsonlite
    #> License: Apache License (== 2.0)
    #> Description: Open-source gradient boosting on decision trees with
    #>         categorical features support out of the box.
    #> Authors@R: c( person("Nikita", "Dmitriev", role = "aut"),
    #>         person("Andrey", "Gulin", role = "aut", comment = "Chief
    #>         researcher, author of the algorithm and of the first
    #>         implementation"), person("Anna Veronika", "Dorogush", role =
    #>         "aut"), person("Stanislav", "Kirillov", role = "cre", email =
    #>         "staskirillov@gmail.com"), person("Victor", "Omelyanenko", role
    #>         = "aut"), person("Evgueni", "Petrov", role = "aut"),
    #>         person("Andrey", "Mishenko", role = "aut"), person("Pavel",
    #>         "Kalinin", role = "aut"), person("Vyacheslav", "Alipov", role =
    #>         "aut"), person("Egor", "Samosvat", role = "aut"),
    #>         person("Alexander", "Kobotov", role = "aut"), person("Dmitry",
    #>         "Schelchkov", role = "aut"), person("Vasily", "Ershov", role =
    #>         "aut", comment = "GPU implementation"), person("Vyacheslav",
    #>         "Murashkin", role = "aut", comment = "R Package"),
    #>         person("Roman", "Nefyodov", role = "aut", comment = "R
    #>         Package"), person("Anastasia", "Bezzubtseva", role = "aut",
    #>         comment = "R Package"), person("Alexey", "Gorchakov", role =
    #>         "aut", comment = "R Package"), person("Ivan", "Karev", role =
    #>         "aut", comment = "Visualisation"), person("Sergey",
    #>         "Berezhnoy", role = "aut", comment = "Visualisation"),
    #>         person("Roman", "Rybalchenko", role = "aut", comment =
    #>         "Visualisation"), person("Valeriy", "Babushkin", role = "aut",
    #>         comment = "Tutorials"), person("Mikhail", "Pershin", role =
    #>         "aut", comment = "Tutorials"), person("Emil", "Kayumov", role =
    #>         "aut", comment = "Tutorials"), person("Evgeny", "Eltyshev",
    #>         role = "aut", comment = "Tutorials"), person("Alexander",
    #>         "Baranov", role = "aut", comment = "CoreML support"),
    #>         person("Dmitry", "Oganesyan", role = "aut", comment = "R
    #>         Package"), person("CatBoost DevTeam", role = c("aut", "cph")),
    #>         person("WLOG Solutions", role = "ctb", comment = "R package
    #>         preparation for CRAN submission"), person("Dmitry", "Baksheev",
    #>         role = "aut") )
    #> Author: CatBoost DevTeam [aut, cre]
    #> Maintainer: Stanislav Kirillov <staskirillov@gmail.com>
    #> URL: https://catboost.ai/, https://github.com/catboost/catboost
    #> BugReports: https://github.com/catboost/catboost/issues
    #> Suggests: caret, testthat, tibble, e1071
    #> Biarch: FALSE
    #> Encoding: UTF-8
    #> RemoteType: github
    #> RemoteHost: api.github.com
    #> RemoteRepo: catboost
    #> RemoteUsername: catboost
    #> RemoteRef: HEAD
    #> RemoteSha: 7d926816beea530ea97873323f5848fff7c9b474
    #> RemoteSubdir: catboost/R-package
    #> GithubRepo: catboost
    #> GithubUsername: catboost
    #> GithubRef: HEAD
    #> GithubSHA1: 7d926816beea530ea97873323f5848fff7c9b474
    #> GithubSubdir: catboost/R-package
    #> NeedsCompilation: yes
    #> Packaged: 2023-03-18 11:12:33 UTC; maciejnasinski
    #> Built: R 4.2.2; aarch64-apple-darwin20; 2023-03-18 11:12:37 UTC; unix
    #> 
    #> -- File: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/catboost/Meta/package.rds
    

    Created on 2023-03-18 with reprex v2.0.2