Hi, I have 100 price data series like price1, price2, price3, ............. All are "zoo" objects. Now I want to merge all them together. Obviously I can do this using "merge(price1, price2, price3, ........)". However as I have lot of price series (almost 1000) above systax is very tiresome. Is there any other way on doing to in one-go? Thanks -- View this message in context: http://www.nabble.com/Merging-lot-of-zoo-objects-tp24582750p24582750.html Sent from the R help mailing list archive at Nabble.com.
On Tue, Jul 21, 2009 at 9:07 AM, RON70<ron_michael70 at yahoo.com> wrote:> I have 100 price data series like price1, price2, price3, ............. All > are "zoo" objects. Now I want to merge all them together. Obviously I can do > this using "merge(price1, price2, price3, ........)". However as I have lot > of price series (almost 1000) above systax is very tiresome. Is there any > other way on doing to in one-go?How did you get the names price1, price2, ..., price_100 in the first place? Did you make 100 lines of code? If you had stored the objects in a list, such that priceN = list_of_prices[[N]] you could easily define a recursive function to do the job for you. Would it difficult for you to read the data into a list? When dealing with only a few sets, numbering objects as you do is no problem, but for many objects it can become very cumbersome. -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/
1. If the series are zoo series all starting with z, say, in the current workspace then: L <- sapply(ls(pattern = "^z"), get, simplify = FALSE) znew <- do.call("merge", L) 2. If your data originally comes from a single file with a column that specifies which series that row pertains to then you can use read.zoo from the devel version of zoo with the split= argument. # all price series are in one file with # second column containing series id library(zoo) source("http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/R/read.zoo.R?rev=588&root=zoo") znew <- read.zoo("myfile", split = 2, ...whatever...) On Tue, Jul 21, 2009 at 3:07 AM, RON70<ron_michael70 at yahoo.com> wrote:> > Hi, > > I have 100 price data series like price1, price2, price3, ............. All > are "zoo" objects. Now I want to merge all them together. Obviously I can do > this using "merge(price1, price2, price3, ........)". However as I have lot > of price series (almost 1000) above systax is very tiresome. Is there any > other way on doing to in one-go?