[英]sum of two timeseries in R
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 ! 非常感谢您的帮助 !
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])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.