## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 7 ) ## ----packages, message = FALSE------------------------------------------------ library(ackwards) # Fit the raw dataset (not na.omit()) so bfi25's built-in IPIP item labels are # captured and shown by top_items(); missing = "listwise" drops incomplete rows. x <- ackwards(bfi25, k_max = 5, cor = "polychoric", missing = "listwise") ## ----top-items-5-------------------------------------------------------------- top_items(x, level = 5, cut = 0.5) ## ----top-items-n-------------------------------------------------------------- top_items(x, level = 5, cut = 0.3, n = 4) ## ----top-items-cross---------------------------------------------------------- top_items(x, level = 3, cut = 0.25, by = "item") ## ----own-labels, eval = FALSE------------------------------------------------- # # tidyverse idiom: # labelled::var_label(my_data$item1) <- "Full wording of item 1" # # # or base R, no extra package: # attr(my_data$item1, "label") <- "Full wording of item 1" ## ----sign-example------------------------------------------------------------- top_items(x, level = 2) ## ----lineage------------------------------------------------------------------ summary(x) ## ----edges-weak--------------------------------------------------------------- # Primary-parent edges, weakest last: the bottom rows are where structure shifts tidy(x, what = "edges", primary_only = TRUE, sort = "strength") |> tail() ## ----label-template----------------------------------------------------------- label_template(x) ## ----node-labels-------------------------------------------------------------- autoplot(x, node_labels = c( m5f1 = "Neuroticism", m5f2 = "Extraversion", m5f3 = "Conscientiousness", m5f4 = "Agreeableness", m5f5 = "Openness" )) ## ----set-factor-labels-------------------------------------------------------- x <- set_factor_labels(x, c( m5f1 = "Neuroticism", m5f2 = "Extraversion", m5f3 = "Conscientiousness", m5f4 = "Agreeableness", m5f5 = "Openness" )) ## ----labelled-summary--------------------------------------------------------- summary(x) ## ----labelled-tidy------------------------------------------------------------ head(tidy(x, what = "loadings")) ## ----label-forbes------------------------------------------------------------- autoplot(x, node_labels = label_template(x, style = "forbes")) ## ----label-blank-------------------------------------------------------------- labs <- label_template(x, style = "blank") labs["m5f1"] <- "N" labs["m5f2"] <- "E" labs["m5f3"] <- "C" labs["m5f4"] <- "A" labs["m5f5"] <- "O" autoplot(x, node_labels = labs)