我有一个动物园元素列表。列表如下所示:
> str(a)
List of 4
$ :‘zoo’ series from 2013-08-08 to 2013-09-09
Data: num [1:33] 0 0 0 0 5.62 ...
Index: POSIXct[1:33], format: "2013-08-08" "2013-08-09" "2013-08-10" "2013-08-11" ...
$ :‘zoo’ series from 2013-08-08 to 2013-09-09
Data: num [1:33] 0 0 0 0 0 ...
Index: POSIXct[1:33], format: "2013-08-08" "2013-08-09" "2013-08-10" "2013-08-11" ...
$ :‘zoo’ series from 2013-08-08 to 2013-09-09
Data: num [1:33] 7.4 10.7 0 0 0 ...
Index: POSIXct[1:33], format: "2013-08-08" "2013-08-09" "2013-08-10" "2013-08-11" ...
$ :‘zoo’ series from 2013-08-08 to 2013-09-09
Data: num [1:33] 0 588 0 0 0 ...
Index: POSIXct[1:33], format: "2013-08-08" "2013-08-09" "2013-08-10" "2013-08-11" ...
现在,我可以通过这样做来绘制这些动物园元素的总和:
plot(z <- a[[1]] + a[[2]] + a[[3]] + a[[4]])
我想知道是否有一种简单的方法可以将列表中的所有元素相加。就像是
# PYSEUDO CODE NOT WORKING!
plot(z <- foo(a))
非常感谢!