Skip to content

Commit

Permalink
Rd documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebaron committed Oct 9, 2024
1 parent aa44039 commit 535795b
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 187 deletions.
14 changes: 7 additions & 7 deletions R/matlist.R
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ setMethod("zero_re", "mrgmod", function(.x, ...) {

#' Methods for working with matrix-list objects
#'
#' @param x a matlist object
#' @param ... passed through to other methods
#' @param x a matlist object.
#' @param ... passed through to other methods.
#'
#' @name matlist
#' @rdname matlist
Expand All @@ -259,7 +259,7 @@ NULL
#' @param detailed if `TRUE`, then a simple list of matrices is returned;
#' otherwise, then entire `matlist` object data is returned along with the
#' name of the `class` (e.g. either `omegalist` or `sigmalist`) as well
#' as the `names` of the matrices
#' as the `names` of the matrices.
#' @md
#' @rdname matlist
#' @export
Expand Down Expand Up @@ -381,10 +381,10 @@ setMethod("c", "matlist", function(x,...,recursive=FALSE) {
#' updated, usually making it easier. This "collapsing" of the matrix list
#' is irreversible.
#'
#' @param x a `mrgmod` object
#' @param x a model object.
#' @param name a new name for the collapsed matrix; note that this is the
#' matrix name, not the labels which alias `ETA(n)` or `EPS(n)`; specifying a
#' name will only alter how this matrix is potentially updated in the future
#' name will only alter how this matrix is potentially updated in the future.
#' @param range numeric vector of length 2 specifying the range of matrices
#' to collapse in case there are more than 2. The second element may be `NA`
#' to indicate the length of the list of matrices.
Expand All @@ -406,8 +406,8 @@ setMethod("c", "matlist", function(x,...,recursive=FALSE) {
#' A model object with updated `OMEGA` or `SIGMA` matrix lists.
#'
#' @seealso [collapse_matrix()]
#' @md
#' @rdname collapse_matrices
#' @md
#' @export
collapse_omega <- function(x, range = NULL, name = NULL) {
stopifnot(is.mrgmod(x))
Expand Down Expand Up @@ -442,7 +442,7 @@ collapse_sigma <- function(x, range = NULL, name = NULL) {
#' @inheritParams collapse_omega
#' @param x an object that inherits from `matlist`; this object is most
#' frequently extracted from a model object using [omat()] or [smat()] for
#' `OMEGA` and `SIGMA`, respectively
#' `OMEGA` and `SIGMA`, respectively.
#'
#' @examples
#' omega <- omat(list(dmat(1, 2), dmat(3, 4, 5)))
Expand Down
15 changes: 7 additions & 8 deletions R/mrgsolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -785,23 +785,23 @@ do_mrgsim <- function(x,
#' Basic, simple simulation from model object
#'
#' This is just a lighter version of [mrgsim()], with fewer options.
#' See `Details`.
#' See **Details**.
#'
#' @inheritParams mrgsim
#'
#' @param data can be either event object or data set
#' @param data can be either event object or data set.
#' @param output output data type; the default is `mrgsims`, which returns the
#' default output object; other options include `df` (for data.frame) or
#' `matrix`
#' `matrix`.
#' @param outvars output items to request; if missing, then only captured items
#' will be returned in the output
#' @param Req synonym for outvars
#' will be returned in the output.
#' @param Req synonym for `outvars`.
#'
#' @details
#' There is no pipeline interface for this function; all configuration options
#' (see `Arguments`) must be passed as formal arguments to the function.
#' (see **Arguments**) must be passed as formal arguments to the function.
#' You can't `carry_out`, `Request` specific columns, or pass items in for update.
#' Some other limitations, but only convenience-related. See `Arguments` for
#' Some other limitations, but only convenience-related. See **Arguments** for
#' available options. Specifically, there is no `...` argument for this function.
#' Use the [mrgsolve::update()] method to update the model object.
#'
Expand All @@ -816,7 +816,6 @@ do_mrgsim <- function(x,
#' @seealso [mrgsim_q()], [mrgsim()], [mrgsim_variants]
#'
#' @md
#'
#' @export
qsim <- function(x,
data,
Expand Down
186 changes: 93 additions & 93 deletions R/nmxml.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,60 @@
# along with mrgsolve. If not, see <http://www.gnu.org/licenses/>.


##' Import model estimates from a NONMEM xml file
##'
##' @param run run number
##' @param project project directory
##' @param path the complete path to the \code{run.xml} file
##' @param file deprecated; use \code{path} instead
##' @param root the directory that `path` and `project` are relative to; this is
##' currently limited to the `working` directory or `cppdir`, the directory
##' where the model file is located
##' @param theta logical; if TRUE, the \code{$THETA} vector is returned
##' @param omega logical; if TRUE, the \code{$OMEGA} matrix is returned
##' @param sigma logical; if TRUE, the \code{$SIGMA} matrix is returned
##' @param olabels labels for \code{$OMEGA}
##' @param slabels labels for \code{$SIGMA}
##' @param oprefix prefix for \code{$OMEGA} labels
##' @param sprefix prefix for \code{$SIGMA} labels
##' @param tname name for \code{$THETA}
##' @param oname name for \code{$OMEGA}
##' @param sname name for \code{$SIGMA}
##' @param index the estimation number to return; "last" will return the
##' last estimation results; otherwise, pass an integer indicating which
##' estimation results to return
##' @param xpath xml path containing run results; if the default doesn't work,
##' consider using \code{.//estimation} as an alternative; see details
##' @param env internal
##' @aliases NMXML
##' @details
##' If \code{run} and \code{project} are supplied, the .xml file is
##' assumed to be located in \code{run.xml}, in directory \code{run}
##' off the \code{project} directory. If \code{file} is supplied,
##' \code{run} and \code{project} arguments are ignored.
##'
##' This function requires that the \code{xml2} package
##' be installed and loadable. If \code{requireNamespace("xml2")}
##' fails, an error will be generated.
##'
##' \code{nmxml} usually expects to find run results in the xpath called
##' \code{.//nm:estimation}. Occasionally, the run results are not stored in
##' this namespace but no namespaces are found in the xml file. In this case,
##' the user can specify the xpath containing run results. Consider trying
##' \code{.//estimation} as an alternative if the default fails.
##'
##' @return A list with theta, omega and sigma elements,
##' depending on what was requested
##'
##' @seealso nmext
##'
##' @examples
##'
##' if(requireNamespace("xml2")) {
##' proj <- system.file("nonmem", package = "mrgsolve")
##' mrgsolve:::nmxml(run = 1005, project = proj)
##' }
##'
#' Import model estimates from a NONMEM xml file
#'
#' @param run run number.
#' @param project project directory.
#' @param path the complete path to the `run.xml` file.
#' @param file deprecated; use `path` instead.
#' @param root the directory that `path` and `project` are relative to; this is
#' currently limited to the `working` directory or `cppdir`, the directory
#' where the model file is located.
#' @param theta logical; if TRUE, the `$THETA` vector is returned.
#' @param omega logical; if TRUE, the `$OMEGA` matrix is returned.
#' @param sigma logical; if TRUE, the `$SIGMA` matrix is returned.
#' @param olabels labels for `$OMEGA`.
#' @param slabels labels for `$SIGMA`.
#' @param oprefix prefix for `$OMEGA` labels.
#' @param sprefix prefix for `$SIGMA` labels.
#' @param tname name for `$THETA`.
#' @param oname name for `$OMEGA`.
#' @param sname name for `$SIGMA`.
#' @param index the estimation number to return; "last" will return the
#' last estimation results; otherwise, pass an integer indicating which
#' estimation results to return.
#' @param xpath xml path containing run results; if the default doesn't work,
#' consider using `.//estimation` as an alternative; see details.
#' @param env internal use only.
#' @aliases NMXML
#' @details
#' If `run` and `project` are supplied, the `.xml` file is
#' assumed to be located in `run.xml`, in directory `run`
#' off the `project` directory. If `file` is supplied,
#' `run` and `project` arguments are ignored.
#'
#' This function requires that the xml2 package
#' be installed and loadable. If `requireNamespace("xml2")`
#' fails, an error will be generated.
#'
#' `nmxml` usually expects to find run results in the xpath called
#' `.//nm:estimation`. Occasionally, the run results are not stored in
#' this namespace but no namespaces are found in the xml file. In this case,
#' the user can specify the xpath containing run results. Consider trying
#' `.//estimation` as an alternative if the default fails.
#'
#' @return A list with theta, omega and sigma elements, depending on what was
#' requested.
#'
#' @seealso nmext
#'
#' @examples
#'
#' if(requireNamespace("xml2")) {
#' proj <- system.file("nonmem", package = "mrgsolve")
#' mrgsolve:::nmxml(run = 1005, project = proj)
#' }
#' @md
nmxml <- function(run = numeric(0), project = character(0),
file = character(0), path = character(0),
root = c("working", "cppfile"),
Expand Down Expand Up @@ -219,8 +219,8 @@ nmxml <- function(run = numeric(0), project = character(0),
#' Import model estimates from a NONMEM ext file
#'
#' @inheritParams nmxml
#' @param path full path to NONMEM `ext` file
#' @param read_fun function to use when reading the `ext` file
#' @param path full path to NONMEM `ext` file.
#' @param read_fun function to use when reading the `ext` file.
#'
#' @seealso [nmxml()], [read_nmext()]
#'
Expand Down Expand Up @@ -331,43 +331,43 @@ nm_xml_matrix <- function(x) {
m
}

##' Extract estimates from NONMEM ext file
##'
##' This function retrieves NONMEM estimates for use in the mrgsolve model when
##' `$NMEXT` is invoked. See [nmext()].
##'
##' @param run a run number or run identifier
##' @param project the NONMEM project directory
##' @param file the `ext` file name
##' @param path full path and file name for `ext` file
##' @param read_fun function to read the `ext` file; [data.table::fread()] will
##' be used if available; otherwise [utils::read.table()] is used.
##' @param index selects the table number whose results will be returned;
##' use value "last" to select the last table in the `.ext` file; or pass an
##' integer specifying the table number; in case there is exactly
##' one table in the `.ext` file, pass the value "single" to bypass parsing
##' the file to look for sub tables (this might be useful when BAYES analysis
##' was performed as the only estimation method and there are 10000s of
##' posterior samples in the file)
##'
##' @return A list with param, omega, and sigma in a format ready to be used to
##' update a model object.
##'
##' @examples
##' project <- system.file("nonmem", package = "mrgsolve")
##'
##' est <- read_nmext(1005, project = project)
##'
##' est$param
##'
##' est$omega
##'
##' est$sigma
##'
##' est <- read_nmext(2005, project = project, index = 3)
##'
##' @md
##' @export
#' Extract estimates from NONMEM ext file
#'
#' This function retrieves NONMEM estimates for use in the mrgsolve model when
#' `$NMEXT` is invoked. See [nmext()].
#'
#' @param run a run number or run identifier.
#' @param project the NONMEM project directory.
#' @param file the `ext` file name.
#' @param path full path and file name for `ext` file.
#' @param read_fun function to read the `ext` file; [data.table::fread()] will
#' be used if available; otherwise [utils::read.table()] is used.
#' @param index selects the table number whose results will be returned;
#' use value "last" to select the last table in the `.ext` file; or pass an
#' integer specifying the table number; in case there is exactly
#' one table in the `.ext` file, pass the value "single" to bypass parsing
#' the file to look for sub tables (this might be useful when BAYES analysis
#' was performed as the only estimation method and there are 10000s of
#' posterior samples in the file).
#'
#' @return A list with param, omega, and sigma in a format ready to be used to
#' update a model object.
#'
#' @examples
#' project <- system.file("nonmem", package = "mrgsolve")
#'
#' est <- read_nmext(1005, project = project)
#'
#' est$param
#'
#' est$omega
#'
#' est$sigma
#'
#' est <- read_nmext(2005, project = project, index = 3)
#'
#' @md
#' @export
read_nmext <- function(run = NA_real_,
project = getwd(),
file = paste0(run,".ext"),
Expand Down
6 changes: 3 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ build_path <- function(x) {
return(x)
}

##' Set RNG to use L'Ecuyer-CMRG
##'
##' @export
#' Set RNG to use L'Ecuyer-CMRG
#'
#' @export
mcRNG <- function() base::RNGkind("L'Ecuyer-CMRG")

as_character_args <- function(x) {
Expand Down
4 changes: 2 additions & 2 deletions man/collapse_matrices.Rd

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

4 changes: 2 additions & 2 deletions man/collapse_matrix.Rd

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

6 changes: 3 additions & 3 deletions man/matlist.Rd

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

Loading

0 comments on commit 535795b

Please sign in to comment.