0

I am a beginner in timeseries, I have two datatables with different dates and i'd like to have one datatable with all the dates and the sum of the quantitative value ( money paied by the company), for example I have :

here is the first datatable with the price paied

and here is the second one

and i'd like to have this one :

date         old_price      new_price

02/03/2015     1,7+1,2       5,7+1,7

05/05/2015      5,7+1,7       5,7+2,5

20/08/2015      5,7+2,5       2,3+2,5

08/09/2015       2,3+2,5       2,3+4,7

Thank you very much for your help !

Sotos
  • 51,121
  • 6
  • 32
  • 66
Mouna
  • 1
  • Did you meant `,` as `.`? – akrun May 10 '16 at 09:20
  • 1
    Welcome to Stack Overflow @Mouna. For future reference, please avoid using pictures to present your data. Examples need to be reproducible (using `dput()`)so it is easier for others to help you. [Here is a link](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) to get you started. – Sotos May 10 '16 at 09:22

1 Answers1

0

We can try

d3 <- data.frame(date = c(d1$date, d2$date), stringsAsFactors=FALSE)
d3[c("old_price", "new_price")] <-  Map(function(x,y)
      Reduce(`+`,expand.grid(as.numeric(sub(",", ".", x)), 
           as.numeric(sub(",", ".", y)))), d1[-1], d2[-1])
akrun
  • 874,273
  • 37
  • 540
  • 662