I have two lists that contain 500 data frames. Here is an example of two lists containing 2 data frames each.
l1
[[1]]
X1 X2 X3
1 1 0 0
2 5 1 8
[[2]]
X1 X2 X3
1 0 1 1
2 3 0 4
and
l2
[[1]]
X1 X2 X3
1 1 1 0
2 0 1 1
[[2]]
X1 X2 X3
1 0 1 0
2 0 1 1
I need to sum the last value in a column of a dataframe, to the first value of the same column in a dataframe in a different list. For instance:
l1[[1]]$x1[2] to l2[[1]]$x1[1] ; and l1[[1]]$x3[2] to l2[[1]]$x3[1]
In my example, the intended result should be recorded in the dataframes contained in l2, and should look like this:
> l2
[[1]]
X1 X2 X3
1 6 2 8
2 0 1 1
[[2]]
X1 X2 X3
1 3 1 4
2 0 1 1
I intend to do this with lists that contain 500 dataframes. I would have preference for Dplyr.