From 779bf11e4aeea2c04ad67b9a0f51fee2deece9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABlle=20Salmon?= Date: Tue, 20 Aug 2024 12:45:24 +0200 Subject: [PATCH] docs: add example for `consensus_tree()` (from `fit_hrg()` example) --- R/hrg.R | 8 ++++++++ man/consensus_tree.Rd | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/R/hrg.R b/R/hrg.R index 76f844dfb8d..87626cfd945 100644 --- a/R/hrg.R +++ b/R/hrg.R @@ -253,6 +253,14 @@ fit_hrg <- function(graph, hrg = NULL, start = FALSE, steps = 0) { #' split occurred in the generated network samples, for each internal #' vertices. The order is the same as in the `parents` vector.} #' @family hierarchical random graph functions +#' @examples +#' ## A graph with two dense groups +#' g <- sample_gnp(10, p = 1 / 2) + sample_gnp(10, p = 1 / 2) +#' hrg <- fit_hrg(g) +#' hrg +#' +#' ## The consensus tree for it +#' consensus_tree(g, hrg = hrg, start = TRUE) #' @export consensus_tree <- hrg_consensus_impl diff --git a/man/consensus_tree.Rd b/man/consensus_tree.Rd index dff3b677f17..7368e716039 100644 --- a/man/consensus_tree.Rd +++ b/man/consensus_tree.Rd @@ -40,6 +40,15 @@ argument is given and \code{start} is set to \code{TRUE}, then it starts sampling from the given HRG. Otherwise it optimizes the HRG log-likelihood first, and then samples starting from the optimum. } +\examples{ +## A graph with two dense groups +g <- sample_gnp(10, p = 1 / 2) + sample_gnp(10, p = 1 / 2) +hrg <- fit_hrg(g) +hrg + +## The consensus tree for it +consensus_tree(g, hrg = hrg, start = TRUE) +} \seealso{ Other hierarchical random graph functions: \code{\link{fit_hrg}()},