Skip to contents

Make a quick network graph

Usage

get_net(
  df = NULL,
  cv = NULL,
  n = NULL,
  title = "Model",
  legend = "none",
  gamma = 0.3,
  layout = "fr",
  start = "glasso",
  stepwise = T,
  seed = 1,
  group.id = NA,
  item_label = function(x) gsub("\\D", "", x),
  return.df = F
)

Arguments

df

Data frame

cv

Correlation matrix (if df is NULL)

title

Title of the plot

legend

Legend position

gamma

Gamma parameter for the model selection function, see `ggmModSelect`

layout

Default is "fr". Network layout. See more at `ggraph::ggraph`

start

Default is "glasso", see `ggmModSelect`

stepwise

Default is TRUE, see `ggmModSelect`

seed

Attempt to make plots replicable.

group.id

Vector of regex expressions to apply to variable names and use it to group variables.

item_label

Function that converts the item names to node labels.

return.df

Logical, if true, returns tidygraph dataset instead of the plot.

Examples

data("HolzingerSwineford1939", package = "lavaan")
get_net(HolzingerSwineford1939[, 7:15],
       group.id = c(first.factor = "1|2|3",
                    second = "4|5|6",
                    third = "7|8|9"),
       legend = "bottom"
)
#> Loading required package: qgraph
#> Warning: there is no package called ‘qgraph’
#> Loading required package: tidygraph
#> Warning: there is no package called ‘tidygraph’
#> Loading required package: ggraph
#> Warning: there is no package called ‘ggraph’
#> Error in ggmModSelect(cv, n = n, stepwise = stepwise, gamma = gamma, criterion = "ebic",     start = start, nCores = 6): could not find function "ggmModSelect"