R/summary.netconnection.R

Defines functions print.summary.netconnection summary.netconnection

Documented in print.summary.netconnection summary.netconnection

#' Summary method for objects of class netconnection
#' 
#' @description
#' Summary method for objects of class \code{netconnection} to print
#' list of studies in subnetworks.
#' 
#' @param object An object of class \code{netconnection}.
#' @param x An object of class \code{summary.netconnection}.
#' @param \dots Additional arguments (passed on to
#'   \code{\link{print.netconnection}}.
#' 
#' @author Guido Schwarzer \email{guido.schwarzer@@uniklinik-freiburg.de}
#' @seealso \code{\link{netconnection}}
#' 
#' @examples
#' # Artificial example with two subnetworks
#' #
#' t1 <- c("G", "B", "B", "D", "A", "F")
#' t2 <- c("B", "C", "E", "E", "H", "A")
#' #
#' nc2 <- netconnection(t1, t2)
#' print(nc2, details = TRUE)
#' 
#' summary(nc2)
#'
#' @method summary netconnection 
#' @export

summary.netconnection <- function(object, ...) {
  
  chkclass(object, "netconnection")
  
  res <- object
  #
  class(res) <- c("summary.netconnection", class(res))
  #
  res
}


#' @rdname summary.netconnection
#' @method print summary.netconnection 
#' @export

print.summary.netconnection <- function(x, ...) {
  
  chkclass(x, "summary.netconnection")
  #
  class(x) <- "netconnection"
  print(x, ...)
  #
  for (i in seq_len(x$n.subnets)) {
    cat(paste0("\n*** Subnet ", i, " ***\n"))
    #
    cat("\nTreatments:\n ")
    cat(paste(paste0("'", sort(unique(c(x$treat1[x$subnet == i],
                                        x$treat2[x$subnet == i]))), "'"),
              collapse = ", "))
    #
    cat("\nStudies:\n ")
    cat(paste(paste0("'", sort(unique(x$studlab[x$subnet == i])), "'"),
              collapse = ", "))
    cat("\n")
  }
  #
  invisible(NULL)
}

Try the netmeta package in your browser

Any scripts or data that you put into this service are public.

netmeta documentation built on Jan. 28, 2026, 9:06 a.m.