R: Combine list of data frames into single data frame, add column with list index
问题 The question is very similar to this one . It is for combining a list of data frames into a single longer data frame. However, I want to keep the information from which item of the list the data came from by adding an extra column with the index (id or source) of the list. This is the data (borrowing code from the linked example): dfList <- NULL set.seed(1) for (i in 1:3) { dfList[[i]] <- data.frame(a=sample(letters, 5, rep=T), b=rnorm(5), c=rnorm(5)) } Using the code below provides a