Getting Started with {golem}

Colin Fay

2019-07-19

Installing {golem}

{golem} can be installed from GitHub using the {remotes} package:

remotes::install_github("Thinkr-open/golem")

Getting started

Note before using {golem}:

In the rest of the Vignettes, we’ll assume you’re working in RStudio.

Create a package

Once the package is installed, you can got to File > New Project… in RStudio, and choose “Package for Shiny App Using golem” input.

If you want to do it through command line, you can use:

This command allows you to create “illegally-named” package (for example, 1234) by passing the check_name argument to FALSE. Note that this is not recommanded and should only be done if you know what you are doing.

Once you’ve got that, a new RStudio project will be launched. Here is the structure of this project:

DESCRIPTION               
¦--dev/          
  ¦--01_start.R           
  ¦--02_dev.R           
  ¦--03_deploy.R           
  ¦--run_dev.R
¦--inst/ 
  ¦--app                
    ¦--server.R       
    ¦--ui.R           
    ¦--www/          
      ¦--favicon.ico
¦--man/ 
    ¦--run_app.Rd      
NAMESPACE
myapp.Rproj
¦--R/ 
  ¦--app_server.R       
  ¦--app_ui.R           
  ¦--run_app.R      

]

If you’re already familiar with R packages, most of these files will seem very familiar to you. That’s because a {golem} app IS a package.

dev/01_start.R

Once you’ve created your project, the first file that opens is dev/01_start.R. This file contains a series of commands that you’ll have to run once, at the beginning of the project.

Fill the DESC

First, fill the DESCRIPTION by adding information about the package that will contain your app. The first function, fill_desc(), can be used to fil your DESCRIPTION file.

Add {golem} options

Please DO run this line of code, as it sets a series of global options to be reused inside {golem}.

Set common Files

If you want to use the MIT licence, README, code of conduct, lifecycle badge, and news

See {usethis} for more info about these functions.

Add a data-raw folder

If you have data in your package:

About data in a package.

Init Tests

Create a template for tests:

About tests in a package.

Add various tools

Note that you can add an url, and the favicon will be downloaded to the inst/app/www folder.

These two functions add a file with various functions that can be used along the process of building your app.

See each file in details for a description of the functions.

Try the app

To run the app, go to the dev/run_dev.R file, and launch the all thing.

You’re now set! You’ve successfully initiated the project and can go to dev/02_dev.R.

rstudioapi::navigateToFile("dev/02_dev.R")