The code in this repository is used to assist with administration of the Scottish Public Sector shinyapps.io account (scotland.shinyapps.io).
-
You must be a member of the
scotlandshinyapps.io account. -
You must have registered the
scotlandaccount in RStudio using an account token and secret. This can be done using the following code:rsconnect::setAccountInfo( name = "scotland", token = "", secret = "" ) -
You must have access to the
AdministrationShinyappsADM database used to store the data. -
You must have access to the Microsoft Form used to collect contact data, and the Excel spreadsheet where responses are stored.
- If you are not the owner of the Excel spreadsheet, you will also need to download a copy before running any code.
-
You must have the
shinyadminpackage installed. To do this in RStudio, navigate to the 'Build' tab (usually in top-right pane) and click 'Install'.
There are three sources of data:
-
App data from the shinyapps.io server
A snapshot of this data is taken in script 1 and written to ADM in the table
server_apps. -
Contact data collected via a Microsoft Form
A snapshot of this data is taken in script 2 and written to ADM in the table
contacts_new. -
Historic contact data collected via a Google form
This data is stored in the ADM table
contacts_old.
Scripts 3 and 4 use these data sources to produce an analysis table, stored in ADM as analysis.
The following chart visualises how these three data sources are processed and linked to create the analysis table. ADM table names are in bold.
flowchart TB
google("`Google Form Contact Data <br> **contacts_old**`")
msform("`Microsoft Form Contact Data <br> **contacts_new**`")
contacts("`Contact Data <br> **contacts_all**`")
shiny("`Shiny Server App Data <br> **server_apps**`")
analysis("`Analysis Dataset <br> **analysis**`")
shiny --> analysis
msform --> contacts
google --> contacts
contacts --> analysis
To run the process, you need to create a config.yml file.
This file isn't tracked by git, however the expected format can be seen in config-example.yml.
The following parameters are required:
-
adm_server: The value passed to theserverargument ofRtoSQLServer::write_dataframe_to_db. -
ms_form_link: The URL of the Excel spreadsheet of form responses in OneDrive online. -
ms_form_path: The file path to where the Excel spreadsheet of form responses is stored locally. If you are not the owner of the Microsoft Form and are unable to access this via File Explorer, you will have to download a copy of the shared file from OneDrive online. The file path should then be to where you have stored this downloaded copy.
Note that for the Excel spreadsheet of form responses, both the URL (ms_form_link) and the local file path (ms_form_path) are required.
The URL is used to open the Excel file in a browser.
This must be done to refresh the file with the latest responses from the MS Form.
The local file path is used to read the data into R.
-
Create
config.ymlfile. -
Run the scripts in the
scripts/folder one by one in their numbered order.
These are stored in the outputs/ folder.
-
An Excel spreadsheet containing all available data, split by organisation.
- Script 5 produces this file containing information for all organisations.
To produce this file for one organisation only, use the
excel_output()function and specify theorg_groupargument.
- Script 5 produces this file containing information for all organisations.
To produce this file for one organisation only, use the
-
A Quarto dashboard containing a more user-friendly summary and detailed breakdown of apps.
Any additional analysis should be carried out using the analysis table on ADM.
The functions defined in the R/ folder are used to form an R package, shinyadmin.
This repository is maintained by the Data Innovation team.
Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.
The documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.