--- title: "demoShiny" author: - name: "Sigbert Klinke" email: sigbert@hu-berlin.de date: "`r format(Sys.time(), '%d %B, %Y')`" output: html_document: toc: true vignette: > %\VignetteIndexEntry{demoShiny} %\VignetteEngine{knitr::rmarkdown} \usepackage[utf8]{inputenc} --- ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` The aim of the package `demoShiny` is to mimic the `demo` functionality for Shiny apps for a package. # Which Shiny apps are available? With `demoShiny` you can get an overview about all apps from the loaded packages: ```{r} library("demoShiny") demoShiny() ``` The output is a data frame with `package::topic` and the file or directory which would be called by `demoShiny`. You can question for specific apps: ```{r} demoShiny('demoShiny') ``` It will deliver all demo apps of the package `demoShiny` **AND** all apps named `demoShiny`! # How to run a single example app? In case that for your topic is just one app available then no list will be returned but the Shiny demo app will be started: ```{r eval=FALSE} # full topic demoShiny('demoShiny::hist') # if only one app is available then it will be run demoShiny('hist') # abbreviation for topics or packages can used demoShiny('d::hist') ``` # App installation for a package in `inst/shiny` If you develop a package then create under `inst` a directory `shiny`. Each subdirectory of `shiny` can contain one app. The name of the subdirectory is the topic name. ```{r} list.files(system.file('shiny', package="demoShiny"), include.dirs=TRUE) ``` As you can see the `shiny` subdirectory of `demoShiny` contains several directories, e.g. `app1`, `silhouette`, and also a file `app1.R`. If you put an R file with the same name as a directory then the R file is sourced instead of calling the app in the directory. The aim is to allow for a specific calls to the app, e.g. by setting URL parameters: ```{r, code=readLines(system.file('shiny', 'hist.R', package='demoShiny')), eval=FALSE} ``` If you want to add some one liner as title then you have to create a file `00Index` in the `shiny` directory: ```{r, code=readLines(system.file('shiny', '00Index', package='demoShiny')), eval=FALSE} ```