I have what is no doubt a simple problem. I have spent the last hour or so looking around for a solution but am clearly missing something. If this is indeed a duplicate please link me to the right way to do this:
Example data:
names <- c("Cycling1.opr", "Cycling2.opr", "Cycling3.opr")
mydf1 <- data.frame(V1=c(1:5), V2=c(21:25))
mydf2 <- data.frame(V1=c(1:10), V2=c(21:30))
mydf3 <- data.frame(V1=c(1:30), V2=c(21:50))
opr <- list(mydf1,mydf2,mydf3)
mydf4 <- data.frame(timestamp=c(1:5))
mydf5 <- data.frame(timestamp=c(1:10))
mydf6 <- data.frame(timestamp=c(1:30))
timestamp <- list(mydf4,mydf5,mydf6)
names(opr) <- names
names(timestamp) <- names
Each list (opr and timestamp) always has the same number of data.frames and when having the same name, each of these data.frames is always the same length. What I would like to do is merge each similarly named dataframe into a single dataframe as part of a final list (perhaps named finalopr) such that its structure is as follows.
dput(finalopr)
list(structure(list(V1 = 1:5, V2 = 21:25, timestamp = 1:5), .Names = c("V1",
"V2", "timestamp"), row.names = c(NA, -5L), class = "data.frame"),
structure(list(V1 = 1:10, V2 = 21:30, timestamp = 1:10), .Names = c("V1",
"V2", "timestamp"), row.names = c(NA, -10L), class = "data.frame"),
structure(list(V1 = 1:30, V2 = 21:50, timestamp = 1:30), .Names = c("V1",
"V2", "timestamp"), row.names = c(NA, -30L), class = "data.frame"))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…