The goal of shinysnippets is to save development time while taking advantage of Rstudio snippets for Shiny applications.
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.
Copy and paste these snippets to Tools > Global Options > Code > Editing > Edit Snippets.
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")
snippet observe_event
observeEvent( ${1:event} , {
})
snippet sidebar_page
library(shiny)
ui <- fluidPage(
titlePanel( "${1:title}" ),
sidebarLayout(
sidebarPanel(
),
mainPanel(
)
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
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.