Skip to content

ThinkR-open/shinysnippets

master
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
R
 
 
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

shinysnippets

R build status

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} , {
    
    })

sidebar_page

snippet sidebar_page
    library(shiny)
    
    ui <- fluidPage(
      titlePanel( "${1:title}" ), 
      
      sidebarLayout(
        sidebarPanel(
        
        ),
        mainPanel(
        
        )
      )
    )
    
    server <- function(input, output, session) {
      
    }
    
    shinyApp(ui, server)

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.