knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(dplyr, quietly = TRUE)
library(ggplot2, quietly = TRUE)
library(orgsurveyr, quietly = TRUE)

Introduction

This vignette details the steps required to set up and configure the orgsurveyr package, in particular how to use the shiny applications embedded within the package.

Running shiny apps within RStudio

General approach

To run the test_viz shiny app within RStudio type the name of the function:

test_viz()

Other shiny apps:

Further configuration

Whilst the test_viz function has no parameters, the orgviz function takes two parameters, tg and df. These allow the user to pass a tidygraph object and a data frame containing summary metrics for the organisation into the shiny app for plotting. For example:

orgviz(tg = orgsurveyr::tg_org, df = orgsurveyr::tg_org_summarised_df)

Running apps on a Shiny Server

General approach

Assuming that a Shiny Server is available and the orgsurveyr package is installed, it is a case of constructing a shiny app file as follows:

library(shiny)
library(orgsurveyr)

shinyApp(ui = test_viz_ui(),
         server = function(input, output) {
           test_viz_server(input, output)
         }
)

This can be modified as required and copied to the user's shiny server directory.

For convenience there is a make_shiny_app function which creates a template shiny application file like that above for both the test_viz and orgviz shiny apps.

Further configuration

A shiny app file for the orgviz package which includes custom data might look like this:

library(shiny)
library(orgsurveyr)

my_tg <- orgsurveyr::tg_org
my_df <- orgsurveyr::tg_org_summarised_df

shinyApp(ui = orgviz_ui(),
         server = function(input, output) {
           orgviz_server(input, output, tg = my_tg, df = my_df)
         }
)

Docker

The orgsurveyr package can be installed and run within a Docker container that runs both RStudio Server and Shiny Server. This is a convenient way of trying out the Shiny apps with minimal setup overhead and is also a useful way to learn how to configure a Shiny Server. See the README on the package's GitHub repository README for more information.

Session Info

sessionInfo()


ukgovdatascience/orgsurveyr documentation built on May 4, 2019, 7:41 p.m.