My question might be not so clear so I am putting an example.
My final goal is to produce
final=(df1$a*df2$b)+(df1$a*df3$c*df4$d)+(df4$d*df5$e) I have five data frames (one column each) with different lengths as follows:
df1
a 1. 1 2. 2 3. 4 4. 2 df2
b 1. 2 2. 6 df3
c 1. 2 2. 4 3. 3 df4
d 1. 1 2. 2 3. 4 4. 3 df5
e 1. 4 2. 6 3. 2 So I want a final database which includes them all as follows
finaldf
a b c d e 1. 1 2 2 1 4 2. 2 6 4 2 6 3. 4 NA 3 4 2 4. 2 NA NA 3 NA I want all the NAs for each column to be replaced with the mean of that column, so the finaldf has equal length of all the columns:
finaldf
a b c d e 1. 1 2 2 1 4 2. 2 6 4 2 6 3. 4 4 3 4 2 4. 2 4 3 3 4 and therefore I can produce a final result for final=(df1$a*df2$b)+(df1$a*df3$c*df4$d)+(df4$d*df5$e) as I need.