--- title: "Getting started with the tna package" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting started with the tna package} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, fig.width = 10, fig.height = 6, out.width = "100%", dpi = 300, comment = "#>" ) suppressPackageStartupMessages({ library("tna") library("tibble") library("dplyr") library("gt") }) ``` This vignette showcases some basic usage of the `tna` package. First we load the package that we will use for this example. ```{r, eval = FALSE} library("tna") library("tibble") library("dplyr") library("gt") ``` We also load the `engagement` data available in the package (see `?engagement` for further information) ```{r} data("engagement", package = "tna") ``` We build a TNA model using this data with the `tna()` function . ```{r} tna_model <- tna(engagement) ``` To visualize the model, we can use the standard `plot()` function. ```{r} plot(tna_model) ``` The initial state probabilities are ```{r} data.frame(`Initial prob.` = tna_model$inits, check.names = FALSE) |> rownames_to_column("Engagement state") |> arrange(desc(`Initial prob.`)) |> gt() |> fmt_percent() ``` and the transitions probabilities are ```{r} tna_model$weights |> data.frame() |> rownames_to_column("From\\To") |> gt() |> fmt_percent() ``` The function `centralities()` can be used to compute various centrality measures (see `?centralities` for more information). These measures can also be visualized with the `plot()` function. ```{r} centrality_measures <- c("BetweennessRSP", "Closeness", "InStrength", "OutStrength") cents_withoutloops <- centralities( tna_model, measures = centrality_measures, loops = FALSE, normalize = TRUE ) plot(cents_withoutloops, ncol = 2, model = tna_model) ```