[R] R Newbie: quantmod and zoo: Warning in rbind.zoo(...) : column names differ
Achim Zeileis
Achim.Zeileis at wu-wien.ac.at
Wed Sep 3 02:38:08 CEST 2008
On Wed, 3 Sep 2008, Aval Sarri wrote:
> Hello;
>
> I am trying following but getting a warning message : Warning in
> rbind.zoo(...) : column names differ, no matter whatever I do.
>
> Also I do not want to specify column names manually, since I am just
> writing a wrapper function around getSymbols to get chunks of data
> from various sources - oanda, dividends etc.
>
> I tried giving col.names = T/F, header = T/F and skip = 1 but no help.
>
> I think problem is that getSymbols returns a zoo objects whose
> index/first column is null. I write these data in a file and read it
> again using read.zoo; when I try to append to these data (using one
> more call to getSymbols) it throws this warning message.
The data in objects part1 and part3 are both matrices of dimension 10x1
and 11x1, respectively, with column name USD.EUR. part2, on the other
hand, contains a vector of length 10 and consequently has no column names.
Hence, column matching does not work and the c()/rbind() method complains.
The easiest thing is to turn part3 into a vector and then combine
c(part2, part3[,1])
The reason for part2 being different is the following: zoo seems to drop
the dimension of 1-column series in a few places, e.g., in read.zoo().
I just added a drop = TRUE argument to read.zoo() in the devel version.
hth,
Z
>
> <code>
> library("quantmod")
> options(warn = 1)
>
> part1<-getSymbols(Symbols="USD/EUR", src="oanda", from="2008-01-01",
> to="2008-01-10", auto.assign=F, return.class="zoo")
> print(dimnames(part1))
> write.zoo(part1,"USDEUR", col.names=T) # writes as
>
> part2 <- read.zoo("USDEUR", header=T)
> print (dimnames(part2)) # dinames or attributes
>
> part3<-getSymbols(Symbols="USD/EUR", src="oanda", from="2008-01-21",
> to="2008-01-31", auto.assign=F, return.class="zoo")
> print(dimnames(part3))
>
> allpart <- c(part2, part3)
> cat ("-----allparts----\n")
> print(dimnames(allpart))
>
> write.zoo (allpart, "USDEUR.all", col.names=T)
> </code>
>
> I am not sure how to handle this, please kindly provide some pointer.
>
> Thanks and Regards
> -Aval.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
More information about the R-help
mailing list