../vignettes/package_setup.Rmd
package_setup.RmdThis 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.
To run the test_viz shiny app within RStudio type the name of the function:
test_viz()Other shiny apps:
test_viz - simulates an organisation with different characteristicsorgviz - permits visualisation of either simulated or real data as long as the data formats described in orgsurveyr-data-formats as used.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)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.
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)
}
)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.
sessionInfo()
#> R version 3.5.1 (2018-07-02)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Debian GNU/Linux 9 (stretch)
#>
#> Matrix products: default
#> BLAS: /usr/lib/openblas-base/libblas.so.3
#> LAPACK: /usr/lib/libopenblasp-r0.2.19.so
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=C
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] orgsurveyr_0.6.0 ggplot2_3.0.0 dplyr_0.7.6
#>
#> loaded via a namespace (and not attached):
#> [1] tidyselect_0.2.4 purrr_0.2.5 colorspace_1.3-2
#> [4] htmltools_0.3.6 viridisLite_0.3.0 yaml_2.2.0
#> [7] rlang_0.2.2 pkgdown_1.2.0.9000 pillar_1.3.0
#> [10] later_0.7.5 glue_1.3.0 withr_2.1.2
#> [13] tweenr_1.0.0 bindrcpp_0.2.2 bindr_0.1.1
#> [16] plyr_1.8.4 stringr_1.3.1 munsell_0.5.0
#> [19] commonmark_1.5 gtable_0.2.0 memoise_1.1.0
#> [22] evaluate_0.11 knitr_1.20 httpuv_1.4.5
#> [25] Rcpp_0.12.18 xtable_1.8-3 scales_1.0.0
#> [28] backports_1.1.2 promises_1.0.1 desc_1.2.0
#> [31] mime_0.5 farver_1.0 fs_1.2.6
#> [34] gridExtra_2.3 ggforce_0.1.3 digest_0.6.17
#> [37] stringi_1.2.4 ggrepel_0.8.0 shiny_1.1.0
#> [40] grid_3.5.1 rprojroot_1.3-2 tools_3.5.1
#> [43] magrittr_1.5 lazyeval_0.2.1 tibble_1.4.2
#> [46] ggraph_1.0.2 crayon_1.3.4 pkgconfig_2.0.2
#> [49] MASS_7.3-50 xml2_1.2.0 assertthat_0.2.0
#> [52] rmarkdown_1.10 roxygen2_6.1.0 rstudioapi_0.7
#> [55] viridis_0.5.1 R6_2.2.2 units_0.6-1
#> [58] igraph_1.2.2 compiler_3.5.1