The goal of shinysnippets is to save development time while taking advantage of Rstudio snippets for Shiny applications.

Installation of snippets

Via the package

You can install the dev of {shinysnippets} from GitHub:

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

Then run:

shinysnippets::add_snippets()

You’ll be asked to validate the writing of the snippets in ~/.R/snippets/r.snippets.

Restart RStudio to make these snippets effective.

Manually

Copy and paste these snippets to Tools > Global Options > Code > Editing > Edit Snippets.

Snippets list

Modules

snippet module
    ${1:name}ui <- function(id){
        ns <- NS(id)
        tagList(
        
            )
        }

    ${1:name} <- function(input, output, session){
        ns <- session\$ns
    }
    
    # Copy in UI
    ${1:name}ui("${1:name}ui")
    
    # Copy in server
    callModule(${1:name}, "${1:name}ui")

observeEvent

snippet observe_event
    observeEvent( ${1:event} , {
    
    })

withProgress

snippet with_progress
    withProgress( message = "${1:message}" , {
    
    })

Please note that the ‘shinysnippets’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.