Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

shinyAppTemplate

Generate a Shiny application from a template


Description

This function populates a directory with files for a Shiny application.

Usage

shinyAppTemplate(path = NULL, examples = "default", dryrun = FALSE)

Arguments

path

Path to create new shiny application template.

examples

Either one of "default", "ask", "all", or any combination of "app", "rdir", "module", "shinytest", and "testthat". In an interactive session, "default" falls back to "ask"; in a non-interactive session, "default" falls back to "all". With "ask", this function will prompt the user to select which template items will be added to the new app directory. With "all", all template items will be added to the app directory.

dryrun

If TRUE, don't actually write any files; just print out which files would be written.

Details

In an interactive R session, this function will, by default, prompt the user to select which components to add to the application. Choices are

1: All
2: app.R              : Main application file
3: R/example.R        : Helper file with R code
4: R/example-module.R : Example module
5: tests/shinytest/   : Tests using the shinytest package
6: tests/testthat/    : Tests using the testthat package

If option 1 is selected, the full example application including the following files and directories is created:

appdir/
|- app.R
|- R
|   |- example-module.R
|   `- example.R
`- tests
    |- shinytest.R
    |- shinytest
    |   `- mytest.R
    |- testthat.R
    `- testthat
        |- test-examplemodule.R
        |- test-server.R
        `- test-sort.R

Some notes about these files:

  • app.R is the main application file.

  • All files in the R/ subdirectory are automatically sourced when the application is run.

  • R/example.R and R/example-module.R are automatically sourced when the application is run. The first contains a function lexical_sort(), and the second contains code for module created by the moduleServer() function, which is used in the application.

  • tests/ contains various tests for the application. You may choose to use or remove any of them. They can be executed by the runTests() function.

  • tests/shinytest.R is a test runner for test files in the tests/shinytest/ directory.

  • tests/shinytest/mytest.R is a test that uses the shinytest package to do snapshot-based testing.

  • tests/testthat.R is a test runner for test files in the tests/testthat/ directory using the testthat package.

  • tests/testthat/test-examplemodule.R is a test for an application's module server function.

  • tests/testthat/test-server.R is a test for the application's server code

  • tests/testthat/test-sort.R is a test for a supporting function in the R/ directory.


shiny

Web Application Framework for R

v1.6.0
GPL-3 | file LICENSE
Authors
Winston Chang [aut, cre], Joe Cheng [aut], JJ Allaire [aut], Carson Sievert [aut], Barret Schloerke [aut], Yihui Xie [aut], Jeff Allen [aut], Jonathan McPherson [aut], Alan Dipert [aut], Barbara Borges [aut], RStudio [cph], jQuery Foundation [cph] (jQuery library and jQuery UI library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt), jQuery UI contributors [ctb, cph] (jQuery UI library; authors listed in inst/www/shared/jqueryui/AUTHORS.txt), Mark Otto [ctb] (Bootstrap library), Jacob Thornton [ctb] (Bootstrap library), Bootstrap contributors [ctb] (Bootstrap library), Twitter, Inc [cph] (Bootstrap library), Prem Nawaz Khan [ctb] (Bootstrap accessibility plugin), Victor Tsaran [ctb] (Bootstrap accessibility plugin), Dennis Lembree [ctb] (Bootstrap accessibility plugin), Srinivasu Chakravarthula [ctb] (Bootstrap accessibility plugin), Cathy O'Connor [ctb] (Bootstrap accessibility plugin), PayPal, Inc [cph] (Bootstrap accessibility plugin), Stefan Petre [ctb, cph] (Bootstrap-datepicker library), Andrew Rowls [ctb, cph] (Bootstrap-datepicker library), Dave Gandy [ctb, cph] (Font-Awesome font), Brian Reavis [ctb, cph] (selectize.js library), Salmen Bejaoui [ctb, cph] (selectize-plugin-a11y library), Denis Ineshin [ctb, cph] (ion.rangeSlider library), Sami Samhuri [ctb, cph] (Javascript strftime library), SpryMedia Limited [ctb, cph] (DataTables library), John Fraser [ctb, cph] (showdown.js library), John Gruber [ctb, cph] (showdown.js library), Ivan Sagalaev [ctb, cph] (highlight.js library), R Core Team [ctb, cph] (tar implementation from R)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.