Installation

To install and run this model, you will need to have the following on your machine:

R RStudio Rtools Git

Installing the model

There are a few options for installing this model.

Accessing the code via Git (version control)

To access the model using Git the easiest method is to create a new project in RStudio which links to the NICE github website. Simply click New Project in the right hand of your RStudio screen:

Then select Version Control:

Then choose Git:

Paste in the URL of the NICE repository (https://github.com/nice-digital/NICE-model-repo) in the repository URL and decide where you want the project to be saved on your computer using the Browse functionality. All of your team can access the code then in the same way.

If there is more than one branch of code available as the model is updated you can select what branch of the code to look at on the top right of your screen.

Accessing the code by downloading the model

If you do not wish to access the model via Git you can instead download the code and run the model on your local machine either using RStudio or R.

To do this click the Code button and then Download ZIP:

Extract the zip file to wherever on your machine you want to store the model. We would suggest saving it somewhere other than the Downloads/ folder. Open RStudio and press File then New Project:

Click Existing Directory:

Click on the folder where you have saved the model. Make sure you click fully through until you can see the sub folders. Then press Open and then Create Project.

Installing the model dependencies

You’ll also need to install the model dependencies. Your options for this include:

Installing into current environment

In Model_Structure.R, lines 6 to 28 contain instructions for installing the relevant packages. You can use ctrl+shift+c to uncomment these lines and ctrl+enter to run a line or a group of highlighted lines. You only need to do this once and then should recomment the lines using ctrl+shift+c.

This will install the packages into your current environment. If you want to create an isolated environment to install these packages into, then you can set up an R environment with renv by running:

install.packages("renv")
renv::init()

Install your packages as above, and then keep a record of what you installed by running:

renv::snapshot()

Restoring provided renv

We have created an R environment with all the required packages and the versions we used. You can see the version of R this was set up with in the renv.lock file. To install the dependencies by copying this environment, run the following commands in your R console:

install.packages("renv")
renv::restore()