i have a list with 205 different data.frames in it. Each data frame contains 205 columns and 150 rows
i want to loop through each data frame and select a set of rows and save it in another list.
the list containing 205 data frames looks like this but with different row names and colnames each in each data frame
list1[[1]]
S48 S55 S58 S63 S81 S82
201501 3.882404 4.431433 4.208048 3.804576 4.619146 4.491193
5909 5.073869 6.164607 4.795546 4.344407 4.673163 5.185577
1056 6.099640 5.761811 5.653437 4.442167 6.943914 8.2185407
90993 6.767227 6.744791 5.995674 6.064480 6.599200 6.461070
51268 5.849200 5.049686 4.806815 4.115414 5.216890 5.277743
what i eventuallly want is an output like this for each data frame in list1 (but until i got subsets of 150 rows)
S48 S55 S58 S63 S81 S82
201501 3.882404 4.431433 4.208048 3.804576 4.619146 4.491193
5909 5.073869 6.164607 4.795546 4.344407 4.673163 5.185577
S48 S55 S58 S63 S81 S82
201501 3.882404 4.431433 4.208048 3.804576 4.619146 4.491193
5909 5.073869 6.164607 4.795546 4.344407 4.673163 5.185577
1056 6.099640 5.761811 5.653437 4.442167 6.943914 8.2185407
S48 S55 S58 S63 S81 S82
201501 3.882404 4.431433 4.208048 3.804576 4.619146 4.491193
5909 5.073869 6.164607 4.795546 4.344407 4.673163 5.185577
1056 6.099640 5.761811 5.653437 4.442167 6.943914 8.2185407
90993 6.767227 6.744791 5.995674 6.064480 6.599200 6.461070
S48 S55 S58 S63 S81 S82
201501 3.882404 4.431433 4.208048 3.804576 4.619146 4.491193
5909 5.073869 6.164607 4.795546 4.344407 4.673163 5.185577
1056 6.099640 5.761811 5.653437 4.442167 6.943914 8.2185407
90993 6.767227 6.744791 5.995674 6.064480 6.599200 6.461070
51268 5.849200 5.049686 4.806815 4.115414 5.216890 5.277743
etc. etc.
i want to save all of these data frames in a list so eventually i will have 205 lists (containing a list from subsets of data frames like the data above) and i want to save those 205 list together in one list
here's the code what i have
newlist = list()
for (i in 1:205) {
newlist[[i]] <- lapply(seq(2,150), function(x) list1[[i]][1:x,])
}
the code works though, However it takes up to much memory everytime it goes into the loop. Resulting in a terminate R session error while i run this.
Is there a better solution for this, which doesn't take that much memory?