I am intrested in creating a factor out of 4 variables that were suggested as being one factor in my Factor Analysis. Now i am trying to create exactly this factor to enter in my analysis, however as.factor(x) does not combine my dummy variables.
Asked
Active
Viewed 71 times
-1
-
1Please provide sample data using `data.frame`, `list`, `c`, or `dput`. – r2evans Jun 04 '20 at 22:00
-
@ r2evans i cant provide sample data, since it is confidential. Imagine 4 dummy variables (0/1) and i just want to combine them to one factor – Amy Jun 04 '20 at 22:05
-
Really? If it's "just" dummy variables, then please just ***make fake data*** that looks like your data. I don't care if the data you show us is real data or just 0s and 1s, as long as it is representative *enough* so that you can take any hints or answers from SO and apply it correctly to your own data. Another way to answer that: Imagine being asked to analyze data without having the data. – r2evans Jun 04 '20 at 22:10
-
For instance: `fake1 <- c(0, 1, 1, 1, 0, 0, 0)` is giving us some fake data. Perhaps `frame1 <- data.frame(a=1:4, b=11:14)`. – r2evans Jun 04 '20 at 22:11
-
2i am sorry about my wording, i in no way intended to be rude. To be honest, i dont even know how to create example data from scratch. Sorry again if i was behaving disrespectful – Amy Jun 04 '20 at 22:41
-
2Not disrespectful, Amy. Asking questions well so that strangers can look at it briefly and provide *relevant* input/suggestions ... takes a little effort, and the onus is generally on you, the asker, to make that effort. There are some good references for asking questions well on SO (https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info), it might be beneficial to read their perspective for when you have another question. (As far as forums go, SO does have moments of less-patience, which doesn't help.) – r2evans Jun 04 '20 at 22:47
-
1thank you, i will check this out and keep it in mind. – Amy Jun 04 '20 at 22:49
2 Answers
1
We can use interaction
with(df1, interaction(col1, col2, col3, col4, drop = TRUE))

akrun
- 874,273
- 37
- 540
- 662
1
Are you looking to organize multiple variables into one factor that you can then run a Confirmatory Factor Analysis on? If so, the following example shows how to specify which items in your data set that you want to load onto said factor. Specifying the factor loadings requires the psych
package in R and creating the factor model requires the sem()
function from the sem package.
theoretical_factor_structure <- "
AGREEABLE: A1, A2, A3, A4, A5"
factors_for_CFA <- cfa(text = theoretical_factor_structure,
reference.indicators = FALSE)
CFA_model <- sem(factors_for_CFA, data = CFA_data_split)
Apologies if this was not the question you were asking.

Gian Zlupko
- 26
- 4