[R-SIG-Finance] xts metadata

Pete Brecknock Peter.Brecknock at bp.com
Sat Apr 23 21:15:58 CEST 2011

I would like to attach metadata to an xts series that will hold the name of
the data source system of that series. When this series is subsequently
merged with other xts data objects I would be able to recover this name and
identify its original source system.

My effort below is not returning what I expect. 

# Generate Data
x1 = xts(1:10,Sys.Date()+1:10)
x2 = xts(11:20,Sys.Date()+1:10)
x3 = xts(21:30,Sys.Date()+1:10)
x4 = xts(31:40,Sys.Date()+1:10)
x5 = xts(41:50,Sys.Date()+1:10)

# Simulate Data from Two Different Sources
x12  = merge(x1,x2)   # Data from Data System A
x345 = merge(x3,x4,x5)  # Data from Data System B

# Set metadata
attr(x12,"source") = "A"
attr(x345,"source") = "B"

# All Systems Data
x12345 = merge(x12,x345)

# Query Sources
attr(x12345,"source")      # returns "A"
attr(x12345[,1],"source") # returns "A" 
attr(x12345[,5],"source") # returns "A" expecting "B"

I would gratefully receive any suggestions.

Thanks and kind regards


View this message in context: http://r.789695.n4.nabble.com/xts-metadata-tp3470514p3470514.html
Sent from the Rmetrics mailing list archive at Nabble.com.

More information about the R-SIG-Finance mailing list