@@ -35,24 +35,101 @@ factor_analysis.data.frame <- function(x,
3535 correlation_matrix = correlation_matrix
3636 )
3737
38- .factor_analysis_rotate(
38+ out <- .factor_analysis_rotate(
3939 x ,
4040 n ,
4141 rotation = rotation ,
42- sort = sort ,
43- threshold = threshold ,
4442 correlation_matrix = correlation_matrix ,
4543 ...
4644 )
45+
46+ attr(out , " dataset" ) <- x
47+ attr(out , " type" ) <- " fa"
48+ attr(out , " n" ) <- n
49+ attr(out , " sort" ) <- out
50+ attr(out , " threshold" ) <- threshold
51+ class(out ) <- c(" psych_efa" , class(out ))
52+
53+ out
54+ }
55+
56+
57+ # methods -------------------------
58+ # ' @export
59+ print.psych_efa <- function (x ,
60+ sort = FALSE ,
61+ threshold = NULL ,
62+ labels = NULL ,
63+ ... ) {
64+ if (is.null(threshold )) {
65+ threshold <- attributes(x )$ threshold
66+ }
67+ if (is.null(sort )) {
68+ sort <- attributes(x )$ sort
69+ }
70+ model_parameters(x , sort = sort , threshold = threshold , labels = labels , ... )
71+ }
72+
73+
74+ # ' @export
75+ summary.psych_efa <- function (object ,
76+ sort = FALSE ,
77+ threshold = NULL ,
78+ labels = NULL ,
79+ ... ) {
80+ if (is.null(threshold )) {
81+ threshold <- attributes(object )$ threshold
82+ }
83+ if (is.null(sort )) {
84+ sort <- attributes(object )$ sort
85+ }
86+ out <- model_parameters(object , sort = sort , threshold = threshold , labels = labels , ... )
87+ summary(out , ... )
4788}
4889
4990
91+ # ' @export
92+ predict.psych_efa <- function (object ,
93+ newdata = NULL ,
94+ names = NULL ,
95+ keep_na = TRUE ,
96+ sort = FALSE ,
97+ threshold = NULL ,
98+ labels = NULL ,
99+ verbose = TRUE ,
100+ ... ) {
101+ if (is.null(threshold )) {
102+ threshold <- attributes(object )$ threshold
103+ }
104+ if (is.null(sort )) {
105+ sort <- attributes(object )$ sort
106+ }
107+ out <- model_parameters(object , sort = sort , threshold = threshold , labels = labels , ... )
108+ predict(out , newdata = newdata , names = names , keep_na = keep_na , verbose = verbose , ... )
109+ }
110+
111+
112+ # ' @export
113+ convert_efa_to_cfa.psych_efa <- function (model ,
114+ threshold = NULL ,
115+ names = NULL ,
116+ max_per_dimension = NULL ,
117+ ... ) {
118+ if (is.null(threshold )) {
119+ threshold <- attributes(object )$ threshold
120+ }
121+ sort <- attributes(object )$ sort
122+ out <- model_parameters(object , sort = sort , threshold = threshold , ... )
123+ convert_efa_to_cfa(out , names = names , max_per_dimension = max_per_dimension , ... )
124+ }
125+
126+
127+ # internals -----------------------
128+
50129# ' @keywords internal
51130.factor_analysis_rotate <- function (x ,
52131 n ,
53132 rotation ,
54- sort = FALSE ,
55- threshold = NULL ,
56133 correlation_matrix = NULL ,
57134 ... ) {
58135 if (! inherits(x , " data.frame" )) {
@@ -66,25 +143,15 @@ factor_analysis.data.frame <- function(x,
66143
67144 # Pass correlation_matrix if available
68145 if (is.null(correlation_matrix )) {
69- out <- model_parameters(
70- psych :: fa(x , nfactors = n , rotate = rotation , ... ),
71- sort = sort ,
72- threshold = threshold
73- )
146+ out <- psych :: fa(x , nfactors = n , rotate = rotation , ... )
74147 } else {
75- out <- model_parameters(
76- psych :: fa(
77- correlation_matrix ,
78- nfactors = n ,
79- rotate = rotation ,
80- n.obs = nrow(x ),
81- ...
82- ),
83- sort = sort ,
84- threshold = threshold
148+ out <- psych :: fa(
149+ correlation_matrix ,
150+ nfactors = n ,
151+ rotate = rotation ,
152+ n.obs = nrow(x ),
153+ ...
85154 )
86155 }
87-
88- attr(out , " dataset" ) <- x
89156 out
90157}
0 commit comments