Skip to content

Greetings / Feedbacks from golem user #2

@NathanDrg

Description

@NathanDrg

Hy derryleng,

I just wanted to take a moment to thank you for the excellent work you've done on this repository.
After searching all over internet for a solution to deploy an R Shiny app with golem environment locally, I was finally able to do it using your template !

A few steps that helped me with this (in case someone is interested):

  1. Generate the app.R file using golem::add_rstudioconnect_file()
  2. Copy the full golem app in the "app" folder
  3. Follow all the other steps that derryleng mentionned
  4. Quick adjustments that allows you to specify the sources and versions of your packages:
    • In run.R:
    # Install remotes to access potential remote packages
    if(!('remotes' %in% installed.packages()[,"Package"])){
      install.packages('remotes', repos='http://cran.us.r-project.org/')
    }
    
    # Install missing packages
    if (length(req) > 0) {
        lapply(req, function(package){
          package_infos <- eval(parse(text=paste('list(', package, ')')))
          if(!(package_infos$package %in% installed.packages()[,"Package"])){
            if(package_infos$source == "CRAN"){
              if(!is.null(package_infos$version)){
                remotes::install_version(package = package_infos$package,
                                        upgrade="never",
                                        repos = "https://cloud.r-project.org",
                                        version = package_infos$version)
              } else {
                install.packages(package = package_infos$package,
                                lib = lib_path,
                                repos = "https://cloud.r-project.org",
                                clean = T)
              }
            } else if(package_infos$source == "github"){
              remotes::install_github(package_infos$repo)
            }
          }
        })
    }
    
    # Load packages
    suppressPackageStartupMessages(invisible(lapply(req, function(package){
      package_infos <- eval(parse(text=paste('list(', package, ')')))
      library(package_infos$package, character.only = T)
    })))
    
    • In req.txt:
    source = 'CRAN', package = 'shiny'
    source = 'CRAN', package = 'pkgload'
    source = 'CRAN', package = 'golem', version = '0.4.1'
    source = 'CRAN', package = 'taskscheduleR', version = '1.8'
    source = 'CRAN', package = 'glue', version = '1.6.2'
    source = 'CRAN', package = 'jsonlite', version = '1.8.4'
    source = 'CRAN', package = 'stringr', version = '1.5.1'
    source = 'CRAN', package = 'purrr', version = '1.0.1'
    source = 'CRAN', package = 'dplyr', version = '1.1.4'
    source = 'CRAN', package = 'xml2', version = '1.3.3'
    source = 'CRAN', package = 'shinyWidgets', version = '0.7.6'
    source = 'CRAN', package = 'data.table', version = '1.14.6'
    source = 'CRAN', package = 'tidyr', version = '1.2.1'
    source = 'CRAN', package = 'httr', version = '1.4.7'
    source = 'CRAN', package = 'config', version = '0.3.2'
    source = 'github', package = 'example', repo = 'REPO/example'
    
  5. You sould be good to go !

Thank you once again for your work. I really appreciated it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions