I have four data frames , each data frame has the same number of records and same columns: it looks like this:
CURRENT 30DPD 60DPD 90DPD
1 0.56 56.67 67.6 57.67
2 0.24 56.78 7.6 24.67
3 0.32 56.11 66 34.67
4..........
Now from each df
I am taking the first row and creating a list, then the second row from each table, the third row from each table and so on.
now trying to convert a large list to matrixes and here is the code I am using:
for ( i in 1:3542) {
vec1 <- One[i,]
vec2 <- two[i,]
vec3 <- Three[i,]
vec4 <- Four[i,]
tab[[i]] <- c(vec1,vec2,vec3,vec4)
final[[i]] <-matrix(unlist(tab[[i]]),nr=4,nc=4)
}
In the list, I have 3542 elements and I am getting an error when I use this code.
Error in final[[i]] <- matrix(unlist(tab[[i]]), nr = 4, nc = 4) :
more elements supplied than there are to replace
But if I don't use an index then it works fine but for 3000 elements it would be very time-consuming. Any idea how can I create 3542 seperate matrixes using the list?
Thank you