library(EFAfactors)
set.seed(123)
##Take the data.bfi dataset as an example.
data(data.bfi)
response <- as.matrix(data.bfi[, 1:25]) ## loading data
response <- na.omit(response) ## Remove samples with NA/missing values
## Transform the scores of reverse-scored items to normal scoring
response[, c(1, 9, 10, 11, 12, 22, 25)] <- 6 - response[, c(1, 9, 10, 11, 12, 22, 25)] + 1
## Run CDF function with default parameters.
# \donttest{
CDF.obj <- CDF(response)
print(CDF.obj)
## CDF plot
plot(CDF.obj)
## Get the nfact results.
nfact <- CDF.obj$nfact
print(nfact)
# }
## Limit the maximum number of factors to 8, with populations set to 5000.
# \donttest{
CDF.obj <- CDF(response, nfact.max=8, N.pop = 5000)
print(CDF.obj)
## CDF plot
plot(CDF.obj)
## Get the nfact results.
nfact <- CDF.obj$nfact
print(nfact)
# }
Run the code above in your browser using DataLab