[R-SIG-Finance] Naming conventions for merged XTS columns

Worik Stanton worik.stanton at gmail.com
Wed Oct 10 02:52:26 CEST 2012


When I merge two xts with the same column names a '.1' is appended...

Where does this convention come from and can it be firmly relied on?

Sorry if this is a general 'R' question... But merge acts differently
for data.frames

cheers
Worik

> M <- xts(trunc(3*runif(3)), seq(as.Date(1), as.Date(3), by=1))
> M
           [,1]
1970-01-02    0
1970-01-03    2
1970-01-04    1
> colnames(M) <- 'a'
> N <- xts(trunc(3*runif(3)), seq(as.Date(1), as.Date(3), by=1))
> colnames(N) <- 'a'
> merge(N,M)
           a a.1
1970-01-02 2   0
1970-01-03 1   2
1970-01-04 2   1
>

> merge(as.data.frame(M), as.data.frame(N) )
  a
1 1
2 2
3 2
>


-- 
it does not matter                      I think that I shall never see
how much I dig and dig                    A billboard lovely as a tree
this hole just                      Indeed, unless the billboards fall
keeps getting deeper                      I'll never see a tree at all



More information about the R-SIG-Finance mailing list