Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebaron committed Oct 9, 2024
1 parent d511f50 commit a77e6f0
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 119 deletions.
106 changes: 54 additions & 52 deletions R/chain.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,35 @@
# along with mrgsolve. If not, see <http://www.gnu.org/licenses/>.


##' Request simulated output
##'
##' Use this function to select, by name, either compartments or derived
##' variables that have been captured (see \code{\link{CAPTURE}}) into
##' the simulated output.
##'
##' @param x model object
##' @param ... unquoted names of compartments or tabled items
##'
##' @details
##' There is also a \code{Req} argument to \code{\link{mrgsim}} that can
##' be set to accomplish the same thing as a call to \code{Req} in
##' the pipeline.
##'
##' Note the difference between \code{req} and \code{Req}: the former only
##' selects compartments to appear in output while the latter selects both
##' compartments and captured items. Also, when there are items are explicitly
##' listed in \code{Req}, all other compartments or captured items not listed
##' there are ignored. But when compartments are selected with \code{req}
##' all of the captured items are returned. Remember that \code{req} is
##' strictly for compartments.
##'
##' @examples
##' mod <- mrgsolve::house()
##'
##' mod %>% Req(CP,RESP) %>% ev(amt=1000) %>% mrgsim
##'
##' @export
#' Request simulated output
#'
#' Use this function to select, by name, either compartments or derived
#' variables that have been captured (see [CAPTURE]) into
#' the simulated output.
#'
#' @param x model object.
#' @param ... unquoted names of compartments or tabled items.
#'
#' @details
#' There is also a `Req` argument to [mrgsim()] that can
#' be set to accomplish the same thing as a call to `Req` in
#' the pipeline.
#'
#' Note the difference between `req` and `Req`: the former only
#' selects compartments to appear in output while the latter selects both
#' compartments and captured items. Also, when there are items are explicitly
#' listed in `Req`, all other compartments or captured items not listed
#' there are ignored. But when compartments are selected with `req`
#' all of the captured items are returned. Remember that `req` is
#' strictly for compartments.
#'
#' @examples
#' mod <- mrgsolve::house()
#'
#' mod %>% Req(CP,RESP) %>% ev(amt=1000) %>% mrgsim()
#'
#' @md
#' @export
Req <- function(x,...) UseMethod("Req")

#' @export
Expand All @@ -52,12 +53,12 @@ Req.mrgmod <- function(x,...) {
x
}

##' @rdname Req
##' @export
#' @rdname Req
#' @export
req <- function(x,...) UseMethod("req")

##' @export
##' @rdname Req
#' @export
#' @rdname Req
req.mrgmod <- function(x,...) {
x <- update_request(x,as.character(match.call()[-1]))
x
Expand Down Expand Up @@ -104,25 +105,26 @@ carry.out <- function(x,...) {
x
}

##' Re-scale time in the simulated output
##'
##' @param x model object
##' @param value value by which time will be scaled
##' @param ... passed along
##'
##' @details
##' There is also a \code{tscale} argument to \code{\link{mrgsim}} that can
##' be set to accomplish the same thing as a call to \code{tscale} in
##' the pipeline.
##'
##' @examples
##' # The model is in hours:
##' mod <- mrgsolve::house()
##'
##' # The output is in days:
##' mod %>% tscale(1/24) %>% mrgsim
##'
##' @export
#' Re-scale time in the simulated output
#'
#' @param x model object.
#' @param value value by which time will be scaled.
#' @param ... not used.
#'
#' @details
#' There is also a `tscale` argument to [mrgsim()] that can
#' be set to accomplish the same thing as a call to `tscale` in
#' the pipeline.
#'
#' @examples
#' # The model is in hours:
#' mod <- mrgsolve::house()
#'
#' # The output is in days:
#' mod %>% tscale(1/24) %>% mrgsim()
#'
#' @md
#' @export
tscale <- function(x,value=1,...) {
x@args[["tscale"]] <- value
x
Expand All @@ -131,7 +133,7 @@ tscale <- function(x,value=1,...) {
#' Collect only observation records in the simulated output
#'
#' @param x model object.
#' @param value the value for `obsonly`.
#' @param value use `TRUE` to collect and return observation records only.
#' @param ... not used.
#'
#' @details
Expand Down
2 changes: 1 addition & 1 deletion R/class_mrgmod.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2013 - 2022 Metrum Research Group
# Copyright (C) 2013 - 2024 Metrum Research Group
#
# This file is part of mrgsolve.
#
Expand Down
2 changes: 1 addition & 1 deletion R/env.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ env_eval <- function(x,seed=NULL) {
#' Each model keeps an internal environment that allows the user
#' to carry any `R` object along. Objects are coded in `$ENV`.
#'
#' @param x amodel object.
#' @param x a model object.
#' @param ... passed to [ls()].
#'
#' @md
Expand Down
16 changes: 7 additions & 9 deletions R/events.R
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,13 @@ ev_repeat <- function(x, n, wait = 0, as.ev = FALSE) {
#' Use this function when you want to schedule two or more event objects in time
#' according the dosing interval (`ii`) and additional doses (`addl`).
#'
#' @param ... Event objects or numeric arguments named `wait` or `ii` to
#' implement a period of no-dosing activity in the sequence (see details).
#' @param ID Numeric vector of subject IDs.
#' @param .dots A list of event objects that replaces `...`.
#' @param id Deprecated; use `ID`.
#' @param ... event objects or numeric arguments named `wait` or `ii` to
#' implement a period of no-dosing activity in the sequence (see **Details**).
#' @param ID numeric vector of subject IDs.
#' @param .dots a list of event objects that replaces `...`.
#' @param id deprecated; use `ID`.
#'
#' @details
#'
#' Use the generic [seq()] when the first argument is an event object. If a
#' waiting period (`wait` or `ii`) is the first event, you will need to use
#' [ev_seq()]. When an event object has multiple rows, the end time for that
Expand All @@ -570,7 +569,7 @@ ev_repeat <- function(x, n, wait = 0, as.ev = FALSE) {
#'
#' The doses for the next event line start after all of the doses from the
#' previous event line plus one dosing interval from the previous event line
#' (see examples).
#' (see **Examples**).
#'
#' When numerics named `wait` or `ii` are mixed in with the event objects,
#' a period with no dosing activity is incorporated into the sequence,
Expand All @@ -595,10 +594,9 @@ ev_repeat <- function(x, n, wait = 0, as.ev = FALSE) {
#' warning if you use `.ii`. Please use `ii` instead.
#'
#' Values for `time` in any event object act like a prefix time spacer wherever
#' that event occurs in the event sequence (see examples).
#' that event occurs in the event sequence (see **Examples**).
#'
#' @examples
#'
#' e1 <- ev(amt = 100, ii = 12, addl = 1)
#'
#' e2 <- ev(amt = 200)
Expand Down
2 changes: 1 addition & 1 deletion R/mrgsim_q.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2013 - 2020 Metrum Research Group
# Copyright (C) 2013 - 2024 Metrum Research Group
#
# This file is part of mrgsolve.
#
Expand Down
2 changes: 1 addition & 1 deletion R/nmxml.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2013 - 2023 Metrum Research Group
# Copyright (C) 2013 - 2024 Metrum Research Group
#
# This file is part of mrgsolve.
#
Expand Down
44 changes: 22 additions & 22 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -330,28 +330,28 @@ cvec.character <- as.cvec
##' @keywords internal
s_ <- function(...) as.character(match.call(expand.dots=TRUE))[-1] #nocov

##' Access or clear arguments for calls to mrgsim
##'
##' As a model object navigates a pipeline prior to simulation, arguments are
##' collected to eventually be passed to [mrgsim()]. `simargs` lets you
##' intercept and possibly clear those arguments.
##'
##' @param x model object
##' @param clear logical indicating whether or not to clear `args` from
##' the model object
##' @param which character with length 1 naming a single arg to get
##' @param ... passed along
##'
##' @return If `clear` is `TRUE`, the argument list is
##' cleared and the model object is returned. Otherwise, the argument
##' list is returned.
##'
##' @examples
##' mod <- mrgsolve::house()
##' mod %>% Req(CP, RESP) %>% carry_out(evid, WT, FLAG) %>% simargs()
##'
##' @md
##' @export
#' Access or clear arguments for calls to mrgsim()
#'
#' As a model object navigates a pipeline prior to simulation, arguments are
#' collected to eventually be passed to [mrgsim()]. `simargs()` lets you
#' intercept and possibly clear those arguments.
#'
#' @param x model object.
#' @param clear logical indicating whether or not to clear `args` from
#' the model object.
#' @param which character with length 1 naming a single arg to get.
#' @param ... not used.
#'
#' @return If `clear` is `TRUE`, the argument list is
#' cleared and the model object is returned. Otherwise, the argument
#' list is returned.
#'
#' @examples
#' mod <- mrgsolve::house()
#' mod %>% Req(CP, RESP) %>% carry_out(evid, WT, FLAG) %>% simargs()
#'
#' @md
#' @export
simargs <- function(x, which = NULL, clear = FALSE,...) {

if(clear) {
Expand Down
20 changes: 10 additions & 10 deletions man/Req.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/env_ls.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions man/ev_seq.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/obsonly.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions man/simargs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a77e6f0

Please sign in to comment.