Blog of Sara Jakša

How to Show Factor Analysis Loadings in a Better Form

Last time I was doing the factor analysis on the data to try and show how much do I use the Google in my programming. While the code is fine and it prints the required result, it is not exactly in the form that it easy to continue analysing.

The former code outputs it as a vector (rpy2.robjects.vectors.ListVector), but it acts mostly as a string. Since we are doing data analysis, and factor analysis is a statistical method, string is usually not want we want.

I still continued to use the same Big Five personality test found on http://personality-testing.info/_rawdata/.

On the end I decided that something that looked like list of lists seems to be a good idea. I know that R has a data frame, that would be even better, but I am not sure if something like that exist. Also it seems that list of lists can be put into numpy array, one of the structures that are frequently mentioned on different data analysis tutorials.

    import numpy

    def transmuteLoadings(result:)
        results = str(results).split("\n")
        final = []
        for result in results:
            if "[" in result:
                final.append([result[(8-2)+i*8:(8-2)+i*8+6].strip() if result[(8-2)+i*8:(8-2)+i*8+6].strip() else "" for i in range(len(result)//6-2)])
        return numpy.array(final)

This function expects the vector, kind of like the one that was the result of the function that I described on How Many Pieces of Knowledge from Different Places are Hidden in my Code

I only tested it on the above mentioned data, but I don‘t see the reason why it would not work on other data as well.