factor_segmentation: Runs factor analysis with varimax rotation using the psych...

View source: R/factor_segmentation.R

factor_segmentationR Documentation

Runs factor analysis with varimax rotation using the psych package.

Description

Runs factor analysis with varimax rotation using the psych package.

Usage

factor_segmentation(
  df,
  vars,
  weight_var = NULL,
  num_sols,
  rotate = "varimax",
  fac_assign = "avg_loading"
)

Arguments

df

data.frame of numeric variables.

vars

variables to be used in the factor analysis.

weight_var

if not NULL, a vector that contains weights for each observation. The NULL case is equivalent to all cases being weighted 1.

num_sols

number of segment solutions to run.

rotate

method of rotation for factor analysis. See psych::principal() for more details.

fac_assign

method to use to assign segments to rows. Options are one of c("avg_loading","max_score").

Examples

df <- rsegmenter::test_seg_unlabelled
segment_input_vars <- c("seg1","seg2","seg3","seg4","seg5","seg6","seg7","seg8","seg9","seg10")
factor_segmentation(df = df, vars = segment_input_vars, weight_var = "weight", num_sols=c(2:3),
rotate="varimax", fac_assign="avg_loading")


PrenolanM/rsegmenter documentation built on Aug. 7, 2022, 8:56 p.m.