## Prerequisites

The following need to be installed and available:

• PsN >= 4.4.8
• NONMEM installed with valid license
• RStudio

## First time set up

### Set up code completion

It is highly recommended to set up code completion though as it eases the scripting process.

setup_code_completion()

This will ask for user consent as it will add entries to the user level snippets file.

### Verify installation

The following function checks for availability of PsN via system_nm(), this is a requirement for NMproject. There are also subsequent checks which not mandatory, but recommended for full functionality.

check_installation()
#> Test passed 🎉

Users working on a standalone machines (e.g. laptops and desktops) should expect these tests to pass and for NMproject to work out of the box (provided the pre-requisites are met).

## Custom configuration

More complex environments involving multiple servers and grids may require more configuration. The options shown here aim to facilitate that. You may need the help of an admin.

### NMTRAN checks

If working in a grid environment, it is highly recommended to perform NMTRAN checks prior to sending jobs off the grid. NMTRAN check provides immediate feedback of control file and dataset errors allowing you to address problems quickly just like if you were on a laptop/desktop environment. Without this, having to wait for a job to reach the grid and fail is a much slower (and more annoying) process.

NMproject tries to guess the location to the NMTRAN file in the NONMEM installation directory however if this fails and check_installation() cannot detect it, you will need to specify the NMTRAN command/file with the nm_tran_command() function. See the following for instructions and examples at the bottom of the help file:

nm_tran_command("/opt/NONMEM/nm75/tr/NMTRAN.exe")

To see more examples see ?nm_tran_command.

This setting will reset upon R session restart, if you want to make it permanent see Making configuration changes permanent.

### The system_nm() command

Under the hood, all calls to PsN proceed through the system_nm() command. This is a user configurable function. By default it’s the same as system() on unix systems and shell() on windows. However if the NONMEM server is remote and requires connection (e.g. via SSH), users may want to modify the behaviour of system_nm(). This is possible through setting the option() also named system_nm, e.g. the following allows runs the system() command on a remote machine named clustername:

options(system_nm=function(cmd,...) {

### Via a custom package

If you already have a package you maintain to deliver functions to users, this package can be used to configure set up options via the .onLoad hook. For example, the following will configure custom NMTRAN and code library settings on package load

.onLoad <- function(libname, pkgname){
## custom NMTRAN location
NMproject::nm_tran_command("/opt/NONMEM/nm75/tr/NMTRAN.exe")
## custom code library location
options(code_library_path = "/projects/myorganisation/code_library")
## message to users in interactive sessions
if (interactive()) usethis::ui_done("NMproject configured")

}

The advantage of a package is you can also bundle other functions in there for users to use.