Re: [R] Another quantmod question

From: Russ Abbott <russ.abbott_at_gmail.com>
Date: Sun, 08 May 2011 13:17:27 -0700

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.psych_at_gmail.com>wrote:

> class(mat)
> class(mat[, "A"])
>

	[[alternative HTML version deleted]]

______________________________________________
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. Received on Sun 08 May 2011 - 20:21:16 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 09 May 2011 - 03:40:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive