Hello, I am new to R so a little stuck. I have 164 items as part of a scale development project (n=1271), and I want to set a cutoff of .40 for factor analysis. I tried using logical operators and used this script
Not sure I understand your question, and you have used code from a package without naming it, not shown what things like Q1.0 are, and not included a minimal working example, so you should do this. Say is your 164 items are in a matrix X and you want all values less than .4 turned missing,
Daniel Wright I am conducting FA. Q1.0 is labelled as Q1.0, I did that one first as a test prior to adding the entire script of Q1 through 164. Prior to performing some rotations and analysis I want to set a cut off score of .40. I have 164 items so need to reduce them somewhat. I was running the packages psych and dplyr. loload and tempdf and datafiles I am using to filter out the variables I need from the original .sav file.
If I understand your query, you want to pull (for further use) only those variables having a loading on your chosen factor structure of at least |.40| on at least one factor, correct?
Save the factor loading (or factor pattern, whichever you are using) matrix to a data.frame. Then, take a subset of variables having an absolute value of loadings for one or more factors that meets your specification.
With a one-factor structure, this is pretty simple. Let's assume that the loadings are saved as "mydata$loading," and you want the variables meeting your criterion and related information saved in a dataframe called "keep_variables." The following line will do the trick:
keep_variables .3999, ]
With a multi-factor structure, you have to check each loading for each variable.
Suppose you have a three-factor structure, and the columns for the loadings are mydata$load1, mydata$load2, and mydata$load3, respectively. The following line will pull any variables (and other info) that meet your criterion for any factor:
Hi David Morse yes that's right. Thanks for the response. I ended up manually going through each item after an initial rotation and then saved only the items > .40 to a new dataset. Was a little more laborious I guess but the end result is the same.
I have saved your script for further use. Thanks again,