I have two list of lists with same length
A1<- list(list(data.frame(x=c(1:10),y=c(1:10)),data.frame(x=rep(1,10),y=rep(2,10))),list(data.frame(x=c(11:20),y=c(11:20)),data.frame(x=rep(11,10),y=rep(12,10))))
A2<- list(list(data.frame(x=rep(30,10)),data.frame(x=rep(40,10))),list(data.frame(x=rep(50,10)),data.frame(x=rep(60,10))))
I want to add a new column to the data frames existed in A1and fill it values from A2
in the end, the A1 " list of lists" should look like the following
A3<- list(list(data.frame(x=c(1:10),y=c(1:10),z=rep(30,10)),data.frame(x=rep(1,10),y=rep(2,10),z=rep(40,10))),list(data.frame(x=c(11:20),y=c(11:20),z=rep(50,10)),data.frame(x=rep(11,10),y=rep(12,10),z=rep(60,10))))
I have tried the following code, but it didn't work
A3<- mapply(function(X,Y) {
X$z<- Y
}, X=A1, Y=A2)