Skip to content

Commit a74d168

Browse files
authored
Merge pull request #17 from dom-muston/main
Update documentation and site
2 parents 4a06b15 + 60e5c40 commit a74d168

29 files changed

+381
-239
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
export(class_dynpv)
34
export(dynpv)
45
export(futurepv)
56
export(get_dynfields)

R/dynamic.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ trim_vec <- function(vec){
4848
#' @param dpv_name Name to be given to Dynamic Present Value object created by this function call
4949
#' @returns A list containing `inputs` and `results`.
5050
#' The `inputs` list contains a list of the following parameters called with the function: `uptakes, payoffs, horizon, tzero, prices`, and `discrate`.
51-
#' The `results` output is a `class_dynpv` S7 object that contains the following elements:
51+
#' The `results` output is a [class_dynpv()] S7 object that contains the following elements:
5252
#' - `name`: Name given to the object
5353
#' - `df`: Tibble of calculation results
5454
#' - `ncoh`: Number of cohorts of uptaking patients

R/future.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#' @seealso [dynpv()]
2929
#' @returns A list `inputs`, `results` and `pv`.
3030
#' The `inputs` list contains a list of the following parameters called with the function: `uptakes, payoffs, horizon, tzero, prices`, and `discrate`.
31-
#' The `results` output is a `class_dynpv` S7 object that contains the following elements:
31+
#' The `results` output is a [class_dynpv()] S7 object that contains the following elements:
3232
#' - `name`: Name given to the object
3333
#' - `df`: Tibble of calculation results
3434
#' - `ncoh`: Number of cohorts of uptaking patients (always 1)

R/oop.R

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@
1111
# https://rconsortium.github.io/S7/articles/packages.html#:~:text=Documentation%20and%20exports,/S7/issues/315
1212
# and my documentation of the class_dynpv S7 class just results in a codoc error on calling check()
1313

14-
# @title S7 Class Representing a Dynamic Present Value object
15-
# @description A Dynamic Present Value object has a name and a proscribed dataset.
16-
# @param name Name of object (character string)
17-
# @param df Dataframe of proscribed format, such as generated by `dynamicpv::dynpv()` and `dynamicpv::futurepv()`.
18-
# @return An object of class `class_dynpv`, with additional properties:
19-
# - `ncoh` Number of cohorts of uptaking patients
20-
# - `uptake` Total number of uptaking patients
21-
# - `sum_by_coh` Tibble of summarized calculation results for each uptake cohort
22-
# - `total` Total present value
23-
# - `mean` Average present value per uptaking patient (=total/uptake)
24-
# @export
14+
#' @title S7 Class Representing a Dynamic Present Value object
15+
#' @description A Dynamic Present Value object has a name and a proscribed dataset.
16+
#' @param name Name of object (character string)
17+
#' @param df Dataframe of proscribed format, such as generated by [dynamicpv::dynpv()] and [dynamicpv::futurepv()].
18+
#' @return An object of class [class_dynpv()], with additional properties:
19+
#' - `ncoh` Number of cohorts of uptaking patients
20+
#' - `uptake` Total number of uptaking patients
21+
#' - `sum_by_coh` Tibble of summarized calculation results for each uptake cohort
22+
#' - `total` Total present value
23+
#' - `mean` Average present value per uptaking patient (=total/uptake)
24+
#' @export
25+
#' @name class_dynpv
2526
class_dynpv <- S7::new_class(
2627
name = "class_dynpv",
2728
properties = list(
@@ -106,15 +107,16 @@ class_dynpv <- S7::new_class(
106107
#`-` <- S7::new_generic("-", c("e1", "e2"))
107108
addprod <- S7::new_generic("addprod", c("e1", "e2"))
108109

109-
# @title Method to add two class_dynpv S7 objects together
110-
# @description Add together two objects each of S7 class `class_dynpv`: e1 + mult * e2
111-
# @param e1 First `class_dynpv` object
112-
# @param e2 Second `class_dynpv` object
113-
# @param mult Numeric
114-
# Present value is present value from `e1` plus `mult` times the present value from `e2`.
115-
# Total uptake is the uptake from `e1` plus `mult` times the uptake from `e2`. Take care of this when using `@mean` of the summed object.
116-
# @returns S7 object of class `class_dynpv`
117-
# @export
110+
#' @title Method to add two class_dynpv S7 objects together
111+
#' @description Add together two objects each of S7 class [class_dynpv()]: e1 + mult * e2
112+
#' @param e1 First [class_dynpv()] object
113+
#' @param e2 Second [class_dynpv()] object
114+
#' @param mult Numeric
115+
#' Present value is present value from `e1` plus `mult` times the present value from `e2`.
116+
#' Total uptake is the uptake from `e1` plus `mult` times the uptake from `e2`. Take care of this when using `@mean` of the summed object.
117+
#' @returns S7 object of class [class_dynpv()]
118+
#' @noRd
119+
#' @name addprod.class_dynpv
118120
S7::method(addprod, signature = list(e1 = class_dynpv, e2 = class_dynpv)) <- function(e1, e2, mult) {
119121
# Pull out xdata and subset of ydata; add dpvno=1 or 2 depending on source
120122
xdata <- e1@df |>
@@ -148,30 +150,36 @@ S7::method(addprod, signature = list(e1 = class_dynpv, e2 = class_dynpv)) <- fun
148150
)
149151
}
150152

151-
# @title Method to add two class_dynpv S7 objects together
152-
# @description Add together two objects each of S7 class `class_dynpv`
153-
# @param e1 First `class_dynpv` object
154-
# @param e2 Second `class_dynpv` object
155-
# Present value of `e1+e2` is sum of present values from `e1` and `e2`.
156-
# Total uptake of `e1+e2` is sum of uptake from `e1` and `e2`. Take care of this when using `@mean` of the summed object.
157-
# @returns S7 object of class `class_dynpv`
158-
# @export
153+
#' @title Method to add two class_dynpv S7 objects together
154+
#' @description Add together two objects each of S7 class [class_dynpv()]
155+
#' @param e1 First [class_dynpv()] object
156+
#' @param e2 Second [class_dynpv()] object
157+
#' Present value of `e1+e2` is sum of present values from `e1` and `e2`.
158+
#' Total uptake of `e1+e2` is sum of uptake from `e1` and `e2`. Take care of this when using `@mean` of the summed object.
159+
#' @returns S7 object of class [class_dynpv()]
160+
#' @noRd
161+
#' @name `+`.class_dynpv
159162
S7::method(`+`, signature = list(e1 = class_dynpv, e2 = class_dynpv)) <- function(e1, e2) {
160163
addprod(e1, e2, mult=1)
161164
}
162165

163-
# Method to subtract one class_dynpv S7 object from another
164-
# @description Subtract one object of S7 class `class_dynpv` from another
165-
# @param e1 First `class_dynpv` object
166-
# @param e2 Second `class_dynpv` object
167-
# Present value of `e1-e2` is the present values from `e1` less that from `e2`.
168-
# Total uptake of `e1-e2` is the uptake from `e1` less that from `e2`. Take care of this when using `@mean` of the summed object.
169-
# @returns S7 object of class `class_dynpv`
166+
#' @title Method to subtract one class_dynpv S7 object from another
167+
#' @description Subtract one object of S7 class [class_dynpv()] from another
168+
#' @param e1 First [class_dynpv()] object
169+
#' @param e2 Second [class_dynpv()] object
170+
#' Present value of `e1-e2` is the present values from `e1` less that from `e2`.
171+
#' Total uptake of `e1-e2` is the uptake from `e1` less that from `e2`. Take care of this when using `@mean` of the summed object.
172+
#' @returns S7 object of class [class_dynpv()]
173+
#' @noRd
174+
#' @name `-`.class_dynpv
170175
S7::method(`-`, signature = list(e1 = class_dynpv, e2 = class_dynpv)) <- function(e1, e2) {
171176
addprod(e1, e2, mult=-1)
172177
}
173178

174-
# Define a print method for the class_dynpv class
179+
#' @title Print method for the class_dynpv class
180+
#' @description Print [class_dynpv()] objects
181+
#' @name print.class_dynpv
182+
#' @noRd
175183
S7::method(print, class_dynpv) <- function(x, ...) {
176184
cat("This is a dynamicpv::class_dynpv S7 object, named", x@name, ". \n")
177185
cat(" Number of cohorts: ", x@ncoh, "\n")

docs/404.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSES-THIRD-PARTY.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/budget-impact-applications.html

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)