Eventually, I got it but my solution requires more lines of code. Thank you very much to anyone who has provided a solution and I apologies again for the confusion between the first post and the definitive one.
Stef
myrows.in <- list()
myrows.out <- list()
for (i in c(1:3)){
myrows.in[[i]] <- match(mydf.empty$age,mydf.list[[i]]$age)
myrows.out[[i]] <- match(mydf.list[[i]]$age,mydf.empty$age)
}
myrows.in
myrows.out
#creating an empty list of dataframe
mydf.empty <-
data.frame(age=factor(0:14,levels=c(0:14),ordered=TRUE),Freq=c(rep(0,15)))
mydf.out.list <- list()
for (i in c(1:3)){
mydf.out.list[[i]] <- mydf.empty
}
mydf.out.list
#filling the empty list of dataframe
for (i in c(1:3)){
mydf.out.list[[i]]$Freq[unlist(myrows.out[i])] <-
mydf.list[[i]]$Freq[na.omit(unlist(myrows.in[i]))]
}
mydf.out.list
identical(myout.list[1],mydf.out.list[1])
identical(myout.list[2],mydf.out.list[2])
identical(myout.list[3],mydf.out.list[3])