The problem is as follows: -I’ve got a list of 100 elements. -Each element of the list has three columns and a variable number of rows (seven, eight, twenty, etc.) The objective is to extract from each list element [[x]] the data (except the first row of three columns) as a single row and bind them all in a data frame. It doesen't matter that this generates NA's because each roww has different number of columns (I'll deal with that later)
I’ve tried a loop that runs through each element of the list extracting the desired data as a vector and then rbinds it to a data frame
# Code is kind of rudimentary
for (x in length(My.List)) {
Temp <- My.List[[x]][2:nrow(My.List [[x]]),]
Temp2 <- as.vector(as.matrix(Temp)) %>% as.data.frame() %>% t()
Temp2 <- as.data.frame(Temp2)
Final.DF[x] <- rbind.fill.matrix(Final.DF, Temp2) #tried with rbind also
}
I would expect a data frame were each row belongs to each list element and each column to the data extracted. I get the following error:
Error in
[<-.data.frame(*tmp*, x, value = logical(0)) :
new columns would leave holes after existing columns`