The aim of the package
demoShiny
is to mimic the demo
functionality
for Shiny apps for a package.
With demoShiny
you can get an overview about all apps
from the loaded packages:
library("demoShiny")
#> Loading required package: shiny
demoShiny()
#> demoShiny::correlation View point cloud for a given correlation
#> demoShiny::dbscan Modify eps and nmin for DBSCAN clustering using Swiss Banknote data
#> demoShiny::hist A simple histogram
#> demoShiny::nonparametric_regression Principle of non-parametric regression
#> demoShiny::pca_best_line Principal components: find the best fitting direction
#> demoShiny::pca_max_var Principal components: find the direction with the largest variance of projected points
#> demoShiny::pca_reduction Principal components: show the total variance reduction
#> demoShiny::scagnostics View scatterplots based on scagnostics coefficients for Boston Housing data
#> demoShiny::silhouette Compute silhouette coefficient
#> demoShiny::test_mean Compares the hypothetical distribution in a t-test with the empirical distribution
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:
demoShiny('demoShiny')
#> demoShiny::correlation View point cloud for a given correlation
#> demoShiny::dbscan Modify eps and nmin for DBSCAN clustering using Swiss Banknote data
#> demoShiny::hist A simple histogram
#> demoShiny::nonparametric_regression Principle of non-parametric regression
#> demoShiny::pca_best_line Principal components: find the best fitting direction
#> demoShiny::pca_max_var Principal components: find the direction with the largest variance of projected points
#> demoShiny::pca_reduction Principal components: show the total variance reduction
#> demoShiny::scagnostics View scatterplots based on scagnostics coefficients for Boston Housing data
#> demoShiny::silhouette Compute silhouette coefficient
#> demoShiny::test_mean Compares the hypothetical distribution in a t-test with the empirical distribution
It will deliver all demo apps of the package demoShiny
AND all apps named demoShiny
!
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:
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.
list.files(system.file('shiny', package="demoShiny"), include.dirs=TRUE)
#> [1] "00Index" "correlation"
#> [3] "dbscan" "hist"
#> [5] "hist.R" "nonparametric_regression"
#> [7] "pca_best_line" "pca_max_var"
#> [9] "pca_reduction" "scagnostics"
#> [11] "silhouette" "test_mean"
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:
launch.browser <- function(url) {
# modify URL, which has no effect for app1 :(
url <- sprintf('%s/?lang=%s', url, 'de')
invisible(.Call("rs_shinyviewer", url, getwd(), 3))
}
#
library("shiny")
runApp(system.file('shiny', 'hist', package='demoShiny'), launch.browser=launch.browser)
If you want to add some one liner as title then you have to create a
file 00Index
in the shiny
directory:
correlation View point cloud for a given correlation
dbscan Modify eps and nmin for DBSCAN clustering using Swiss Banknote data
hist A simple histogram
nonparametric_regression Principle of non-parametric regression
pca_best_line Principal components: find the best fitting direction
pca_max_var Principal components: find the direction with the largest variance of projected points
pca_reduction Principal components: show the total variance reduction
scagnostics View scatterplots based on scagnostics coefficients for Boston Housing data
silhouette Compute silhouette coefficient
test_mean Compares the hypothetical distribution in a t-test with the empirical distribution