Let's suppose I have the following data frame:
df <- data.frame(A=c(0),
B=c(0),
C=c(0),
D=c(0),
E=c(0))
Now, I want to introduce in df some vectors like these ones, introducing 0 when a parameter which is contemplated in df but not in the vectors is missing.
Ex1 <- data.frame(B=c(1),
C=c(2),
D=c(4))
Ex2 <- data.frame(A=c(1),
E=c(6))
That means, the result should look like this:
A B C D E
0 0 0 0 0
0 1 2 4 0
1 0 0 0 6