Reputation: 1045
I ran a foreach
loop to build a list of 100 matrices. The output of each loop is one 7x12 matrix. Now, I want to create a scatterplot the last two columns of each of those matrices using ggplot2. To do this, I figure that I need to convert the list into one big data.frame
that would come out to 700x12. Other posters have solved this for a list of vectors but I don't see one that works for my situation. Here is what I have tried:
as.data.frame(matrix(t(unlist(myList)), ncol=12)))
rbind(myList[1:100])
Upvotes: 3
Views: 1250
Reputation: 81
In your foreach loop, why don't you convert the matrix to a dataframe? If x is your matrix, you can just add this to the end:
data.frame(x)
Then you can just use rbind(myList[1:100])
as you have been.
Upvotes: 1