I understand Josh's example: mat <- matrix(1:10, dimnames = list(NULL, "A")) cbind(X = 11:20, Y = mat + 1) cbind(X = 11:20, Y = mat[, "A"] + 1)
In the line, cbind(X = 11:20, Y = mat + 1), it would be nice if an error or warning message were issued to the effect that the "Y = " part is ignored or not applicable or something to that effect. I still don't understand why cbind.xts doesn't do what I expect. If I try what Josh suggests on my xts example, the result is still confusing. > cbind.xts(close, A = close[,"close"]) close close.1 2007-01-03 1416.60 1416.60 2007-01-04 1418.34 1418.34 2007-01-05 1409.71 1409.71 2007-01-08 1412.84 1412.84 2007-01-09 1412.11 1412.11 If this helps: * * * > dput(close) * * structure(c(1416.6, 1418.34, 1409.71, 1412.84, 1412.11), .indexCLASS = "Date", .indexTZ = structure("", .Names = "TZ"), src = "yahoo", updated = structure(1304875186.625, class = c("POSIXct", * * "POSIXt")), class = c("xts", "zoo"), index = structure(c(1167811200, * * 1167897600, 1167984000, 1168243200, 1168329600), tzone = structure("", .Names = "TZ"), tclass = "Date"), .Dim = c(5L, * * 1L), .Dimnames = list(NULL, "close")) * * * I was also unable to convert Josh's matrix example to xts. > as.xts(mat, order.by = rownames()) Error in dimnames(x) : 'x' is missing * * *The order.by parameter is required, but I don't understand the error message and haven't been able to figure out how to fix it. If this helps:* * * * > dput(mat)structure(1:10, .Dim = c(10L, 1L), .Dimnames = list(NULL, "A")) * * * *This suggests that mat already has defined dimnames. So why does as.xts give an error message about dimnames? I was unable to figure out the problem by looking at any of the help files. In particular the help file for **as.xts.methods didn't seem to offer any clarifications--at least none that I could understand.* * * * * *-- Russ * On Sun, May 8, 2011 at 12:26 PM, Joshua Wiley <jwiley.ps...@gmail.com>wrote: > class(mat) > class(mat[, "A"]) > [[alternative HTML version deleted]] ______________________________________________ R-help@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.