Hi,
When running the factanal function in the R tool and in R Studio I get completely different outputs.
The code I am running in Alteryx:
variables <- read.Alteryx("variables", mode="data.frame")
factormodel <- factanal(variables, factors=3, scores='regression', rotation='none') x <- factormodel$scores
I am running it on the same dataset consisting of 8 normalised variables, and before using the function in the R tool I am making sure to explicitly convert these to floats, so I doubt it is a data type issue. I have attached extracts from the outputs.
Does anyone know what I am doing wrong in Alteryx?
Many thanks!
-Edit: I should probably add the format of my outputs:
RStudio: dataframe with dimensions: [Length_of_dataframe] x 3 --> what you would expect
R Tool: dataframe with dimensions: 1 x (3*[Length_of_dataframe]) --> for some reason it concatenated the results into one row vector
Solved! Go to Solution.
Can you please provide us with some sample data to test this against.
Ben
I just tried this with your sample data and my results line up between Alteryx and R Studio.
Could you retest with your sample data?
Ben
The results are the same.
I think you are simply reading the output wrong.
Cell 2, line 1 in your alteryx output is referencing cell 1 line 2 in your R output.
So it's going down then across rather than across and down.
Ben
Thanks for your reply, Ben. I have found my error (I was pretty stupid and should have checked this earlier). The output of my R code is a matrix so I simply needed to convert it to a dataframe before passing it to the workflow.
Code is below (simply wrapping x inside data.frame()):
variables <- read.Alteryx("variables", mode="data.frame") factormodel <- factanal(variables, factors=3, scores='regression', rotation='none') x <- data.frame(factormodel$scores)
write.Alteryx(x, 1)
This gives me a dataframe with the factors as columns, exactly as in R Studio.