Skip to content

Commit

Permalink
Fill in some gaps in vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
pricet1 committed Nov 21, 2024
1 parent 31af44c commit 77f1038
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 80 deletions.
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ repo:
branch: 38-convert-to-r-pkg
template:
bootstrap: 5
bootswatch: yeti
14 changes: 7 additions & 7 deletions pkgdown/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
font-size: 1.4rem;
}

/* h1 { */
/* font-size: 1.7rem; */
/* width: max-content; */
/* min-width: max-content; */
/* margin: 0; */
/* padding: 1.0rem 1.0rem 0.8rem 0; */
/* } */
h1 {
font-size: 2.2rem;
width: max-content;
min-width: max-content;
margin: 0;
padding: 0.8em 0;
}
42 changes: 23 additions & 19 deletions vignettes/config.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ A user-specific `.Renviron` would typically be stored at:

- Windows:

````
C:\Users\YourUsername\.Renviron
````
```
C:\Users\YourUsername\.Renviron
```

Ensure the file name is exactly ".Renviron" (without any file extension like
.txt)

- Linux/macOS:

````
~/.Renviron
````
```
~/.Renviron
```

Create this file if necessary. From within R, the `usethis` package can do this
for you:

```
```{r, eval=FALSE}
# Create a new user-level .Renviron file, or open an existing one for editing
usethis::edit_r_environ("user")
# Or, as this is the default:
Expand All @@ -86,7 +86,7 @@ contain such entries by default.)
The `usethis` package supports creation/editing of a project-level `.Renviron`
file too:

```
```{r, eval=FALSE}
# Create a new project-level .Renviron file, or open an existing one for editing
usethis::edit_r_environ("project")
```
Expand All @@ -99,19 +99,19 @@ effect. This can be achieved by doing one of the following:

- Reload `.Renviron` in a running R session with, e.g.

````
readRenviron("~/.Renviron")
````
```{r, eval=FALSE}
readRenviron("~/.Renviron")
```

(where you shoul replace "~/.Renviron" with the appropriate path to your
`.Renviron` file if it's not in your home directory)

- A temporary alternative to reloading `.Renviron` is to manually override
specific environment variables within the current R session:

```
Sys.setenv(VAR_NAME = "value")
```
```{r, eval=FALSE}
Sys.setenv(VAR_NAME = "value")
```

This can be helpful for testing specific changes without modifying the
environment file.
Expand All @@ -120,11 +120,13 @@ effect. This can be achieved by doing one of the following:

System environment variables for the `dimex` package start with 'DIMEX_'.

[TODO: Add info about the act, ref and test root paths]
```{=comment}
[TODO: Add info about the main, ref and test root paths]
```

| Environment | Variable name | Description |
|:------------|:----------------|:-------------------------------------------------|
| act | DIMEX_STORE | Root path of the dimex Data and Output |
| Environment | Variable name | Description |
|:------------|:----------------|:---------------------------------------------------|
| main | DIMEX_STORE | Root path of the dimex Data and Output |
| ref | DIMEX_STORE_REF | Root path of the dimex 'reference' Data and Output |

## The `config` object for package-level configuration {#pkg-config}
Expand All @@ -138,6 +140,8 @@ basis.

## The `config` template {#config-template}

See also [development](#config-template).

To create a default configuration for the first time and save it to your
personal system, run:

Expand Down Expand Up @@ -166,7 +170,7 @@ so any custom changes would then need to be *manually re-applied*.

## Default `config` values and overriding them {#default-config-values}

Defaults:
### Defaults

[TODO: Describe defaults]

Expand Down
94 changes: 57 additions & 37 deletions vignettes/development.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,68 +28,85 @@ library(dimex)
## About this vignette

This vignette deals with how to use the `dimex` package as a developer. See also
the [introduction to dimex](dimex.html) and [configuration](config.html)
vignettes.
the [Get started](dimex.html) and [Configuration](config.html) vignettes.

## Installation {#install-dev}

Clone the GitHub repository:

```
$ git clone https://github.com/UoMResearchIT/SPFFinalReport.git
```

## Setup

For a development environment:

### devtools

1. Ensure `devtools` is installed. <br>
From the `R` console:
1. Ensure `devtools` is installed:

```{r eval=FALSE}
install.packages("devtools")
```
> install.packages("devtools")

2. Ensure required packages are installed:

```{r eval=FALSE}
install.packages(c("cli", "DescTools", "dplyr", "ggplot2", "gridExtra",
"haven", "lubridate", "magrittr", "openair", "plyr",
"proxy", "purrr", "rappdirs", "raster", "readr",
"reshape2", "scales", "sf", "sp", "stringr",
"truncnorm", "yaml"))
```

2. Ensure required packages are installed. <br>
[TODO: Implement `renv` and add setup instructions]
```{=comment}
[TODO: Implement `renv` and add setup instructions]
```

3. See the [configuration](config.html) vignette for configuration information.
3. See the [Configuration](config.html) vignette for configuration information.

### Some useful dev commands

These commands should be executed from the `R` console.

(Note that when `devtools` is installed, the following commands are usually
bound to keyboard shortcuts in RStudio; these are shown in the comments where
applicable)
applicable.)

- Load the development version of the package:
- Load the development version of the package:

```
# Ctrl/Cmd + Shift + L
> devtools::load_all(".")
```
```{r eval=FALSE}
# Ctrl/Cmd + Shift + L
devtools::load_all(".")
```

- Run the automated test suite:

```
# Ctrl/Cmd + Shift + T
> devtools::test(".")
```
```{r eval=FALSE}
# Ctrl/Cmd + Shift + T
devtools::test(".")
```

- Create package documentation:

```
# Ctrl/Cmd + Shift + D
> devtools::document(roclets = c('rd', 'collate', 'namespace'))
```
```{r eval=FALSE}
# Ctrl/Cmd + Shift + D
devtools::document(roclets = c('rd', 'collate', 'namespace'))
```

- Build the package vignettes:

```
> devtools::build_vignettes()
```
```{r eval=FALSE}
devtools::build_vignettes()
```

- Run a package check:

```
# Ctrl/Cmd + Shift + E
> devtools::check()
```
```{r eval=FALSE}
# Ctrl/Cmd + Shift + E
devtools::check()
```

- Test the current file:

Expand Down Expand Up @@ -145,14 +162,14 @@ applicable)
- To temporarily set a specific high-level data test to run in the current R
session, run (for e.g.):

```
```{r eval=FALSE}
# Set the high-level data test for step "1a" to run
Sys.setenv(DIMEX_RUN_HLDT_1A = "true")
```

To reverse this, do one of the following:

```
```{r eval=FALSE}
Sys.setenv(DIMEX_RUN_HLDT_1A = "false")
# Or:
Sys.unsetenv("DIMEX_RUN_HLDT_1A")
Expand All @@ -161,19 +178,19 @@ applicable)
- To temporarily set all the high-level data tests to run in the current R
session, use:

```
```{r eval=FALSE}
Sys.setenv(DIMEX_RUN_ALL_HLDT = "true")
```

To reverse this, do one of the following:

```
```{r eval=FALSE}
Sys.setenv(DIMEX_RUN_ALL_HLDT = "false")
# Or:
Sys.unsetenv("DIMEX_RUN_ALL_HLDT")
```
### The config template

### The config template {#config-template}

To update the config template, edit the functions [generate_cfg_template()] and
[get_cfg_template_keys()].
Expand All @@ -188,10 +205,13 @@ Note NB: <br>
Changing the template will necessitate updating user config files that have
already been created.

<!-- [TODO: When a conversion utility has been implemented, update the following] -->
```{=comment}
[TODO: When a conversion utility has been implemented, update the following]
```
**There is currently no mechanism to convert the format of a user config file**
*so until such time as this can be implemented, any local changes to a user
config will need to be* **manually updated**.
config will need to be* **manually applied**.

To update the user config, run:
```{r, eval=FALSE}
# NB: The following will *overwrite* any local changes to the user config!
Expand Down
35 changes: 18 additions & 17 deletions vignettes/dimex.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ This package implements the DIMEX model. The package derived from the
SPFFinalReport code (created for the case study and report for the final SPF
reporting period).

See also the [configuration](config.html) and [development](development.html)
See also the [Configuration](config.html) and [Development](development.html)
vignettes.

### Installation
### Installation {#install}

[TODO: TBC]
To install the development version of `dimex` from GitHub:

```{=comment}
<!-- You can install the development version of `dimex` from GitHub with: -->
<!-- # install.packages("remotes") -->
<!-- remotes::install_github("path/dimex") -->
```{r, eval = FALSE}
# install.packages("remotes")
remotes::install_github("https://github.com/UoMResearchIT/SPFFinalReport")
```

See [dimex](#install-dev) for doing development on the `dimex` package.

## Data workflow

### Data phases
Expand Down Expand Up @@ -82,13 +82,11 @@ For each of these data wrangling phases, there are three possible environments:
- small enough to use for unit/integration tests
- can be reliably reproduced

## Getting started

### Configuration
## Configuration

See [configuration](config.html) for configuration information.

### Running the pipeline
## Workflow: Running the pipeline

The main entry point for running the code is the
[run_workflow()](../reference/run_workflow.html)
Expand All @@ -114,15 +112,18 @@ run_workflow("4a, 4b")
run_workflow(banner_only = TRUE)
# Run steps 4a and 4b only, with the specified config
# See the [configuration](config.html) vignette for information on
# See the [Configuration](config.html) vignette for information on
# how to create a non-default config
# # [TODO: Show example of creating a config]
# # cfg = ...
# # cfg_overrides = ...
run_workflow("4a, 4b", cfg = cfg, cfg_overrides = cfg_overrides)
```

```{=comment}
# [TODO: Show example of creating a config in the code chunk above]
# cfg = ...
# cfg_overrides = ...
```

## Development

For doing development work on the `dimex` package, see the
[development](development.html) vignette.
[Development](development.html) vignette.

0 comments on commit 77f1038

Please sign in to comment.