From f4c0748dc028dc0a5d507aea73447999c30bf6c1 Mon Sep 17 00:00:00 2001 From: Santtu Tikka Date: Tue, 19 Mar 2024 17:38:15 +0200 Subject: [PATCH] rename plot arg --- R/plot.R | 19 ++++++++++++++----- man/plot.dynamiteformula.Rd | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/R/plot.R b/R/plot.R index d9a30d9..b1b34b5 100644 --- a/R/plot.R +++ b/R/plot.R @@ -85,7 +85,7 @@ plot.dynamitefit <- function(x, parameters = NULL, type = NULL, #' @export #' @family plotting #' @param x \[`dynamiteformula`]\cr The model formula. -#' @param show_deterministic \[`logical(1)`]\cr Should deterministic auxiliary +#' @param show_auxiliary \[`logical(1)`]\cr Should deterministic auxiliary #' responses be shown in the plot? If `FALSE`, the vertices corresponding #' to such responses will be projected out. The default is `TRUE`. #' @param show_covariates \[`logical(1)`]\cr Should unmodeled covariates be @@ -105,7 +105,7 @@ plot.dynamitefit <- function(x, parameters = NULL, type = NULL, #' # TikZ format #' plot(multichannel_formula, tikz = TRUE) #' -plot.dynamiteformula <- function(x, show_deterministic = TRUE, +plot.dynamiteformula <- function(x, show_auxiliary = TRUE, show_covariates = FALSE, tikz = FALSE, ...) { stopifnot_( !missing(x), @@ -115,11 +115,19 @@ plot.dynamiteformula <- function(x, show_deterministic = TRUE, is.dynamiteformula(x), "Argument {.arg x} must be a {.cls dynamiteformula} object." ) + stopifnot_( + checkmate::test_flag(x = show_auxiliary), + "Argument {.arg show_auxiliary} must be a single {.cls logical} value." + ) + stopifnot_( + checkmate::test_flag(x = show_covariates), + "Argument {.arg show_covariates} must be a single {.cls logical} value." + ) stopifnot_( checkmate::test_flag(x = tikz), "Argument {.arg tikz} must be a single {.cls logical} value." ) - g <- get_dag(x, project = !show_deterministic, covariates = show_covariates) + g <- get_dag(x, project = !show_auxiliary, covariates = show_covariates) ifelse_( tikz, plot_dynamiteformula_tikz(g), @@ -142,8 +150,9 @@ plot_dynamiteformula_tikz <- function(g) { " -semithick,", " >={Stealth[width=1.5mm,length=2mm]},", paste0( - " obs/.style 2 args = ", - "{name = #1, circle, draw, inner sep = 5pt, label = center:$#2$}" + " obs/.style 2 args = {", + " name = #1, circle, draw, inner sep = 5pt, label = center:$#2$", + " }" ), "}", .parse = FALSE diff --git a/man/plot.dynamiteformula.Rd b/man/plot.dynamiteformula.Rd index cab9442..aadd3f5 100644 --- a/man/plot.dynamiteformula.Rd +++ b/man/plot.dynamiteformula.Rd @@ -4,12 +4,12 @@ \alias{plot.dynamiteformula} \title{Plot the Model Structure as a Directed Acyclic Graph (DAG)} \usage{ -\method{plot}{dynamiteformula}(x, show_deterministic = TRUE, show_covariates = FALSE, tikz = FALSE, ...) +\method{plot}{dynamiteformula}(x, show_auxiliary = TRUE, show_covariates = FALSE, tikz = FALSE, ...) } \arguments{ \item{x}{[\code{dynamiteformula}]\cr The model formula.} -\item{show_deterministic}{[\code{logical(1)}]\cr Should deterministic auxiliary +\item{show_auxiliary}{[\code{logical(1)}]\cr Should deterministic auxiliary responses be shown in the plot? If \code{FALSE}, the vertices corresponding to such responses will be projected out. The default is \code{TRUE}.}