Oh, I see, good point. (But should that the column output really have a  
name at all?)

On a similar point I can't get names() to work with xts. Here's an example:

TimeIndex <- Sys.time() + seq(1,5,1); x1 <- rnorm(5); x2 <- rnorm(5)
MyData <- data.frame(TimeIndex, x1, x2)
xtsMyData <- xts(MyData[,-1], MyData[,1]); xtsMyData

names(xtsMyData) <- c("Xone", "Xtwo")
#names(xtsMyData) <- c("Timestamp", "Xone", "Xtwo")

> head(xtsMyData,3)
x1 x2
2009-06-29 19:13:23.825 -1.05527495 -0.4014843
2009-06-29 19:13:24.825 -1.82892230 -1.1080668
2009-06-29 19:13:25.825 -0.09286556 1.6264407

names(MyData) <- c("Timestamp", "Xone", "Xtwo")
> head(MyData, 3)
Timestamp Xone Xtwo
1 2009-06-29 19:13:23.825 -1.05527495 -0.4014843
2 2009-06-29 19:13:24.825 -1.82892230 -1.1080668
3 2009-06-29 19:13:25.825 -0.09286556 1.6264407


Am I doing something wrong?
Thanks



On Jun 29, 2009 1:05pm, Joshua Ulrich <josh.m.ulrich@gmail.com> wrote:
> Hi Ken,



> I'm not sure there's any way for us to *fix* this, since it is a

> result of the ifelse() function. The source below shows the function

> replaces the values of "test" with "yes" or "no" depending on the

> result of "test".



> Further, in the case that the result contains some values from *both*

> columns x2 and x3, it's not clear what the column name should be.



> > ifelse

> function (test, yes, no) {

> storage.mode(test)
> ans
> nas is.na(test)

> if (any(test[!nas]))

> ans[test & !nas]
> if (any(!test[!nas]))

> ans[!test & !nas]
> ans[nas]
> ans

> }







> HTH,

> Josh

> --

> http://www.fosstrading.com







> On Sun, Jun 28, 2009 at 2:19 PM, Kenneth Spriggsksspriggs@gmail.com>  
> wrote:

> > For xts developers. (If this has been covered before I apologize.)

> > The logic ends up fine just the name of the column doesn't actually go

> > with the output...

> >

> > TimeIndex
> > x3
> > BartSimpson
> > xtsBartSimpson
> > QuestionableHeaderName1
> > xtsBartSimpson$x2, xtsBartSimpson$x3); QuestionableHeaderName1

> > QuestionableHeaderName2
> > xtsBartSimpson$x2, xtsBartSimpson$x3); QuestionableHeaderName2

> >

> > x1 x2 x3

> > 2009-06-28 18:54:02 -0.8688258 1.3517895 -0.8920901

> > 2009-06-28 18:54:03 -1.6324798 0.4645305 0.8773917

> > 2009-06-28 18:54:04 0.8754520 -1.1538617 1.2920259

> > 2009-06-28 18:54:05 0.7083217 0.2606429 -0.4256368

> > 2009-06-28 18:54:06 -0.4125602 0.6148270 -0.7822110

> > x1

> > 2009-06-28 18:54:02 1.3517895

> > 2009-06-28 18:54:03 0.4645305

> > 2009-06-28 18:54:04 -1.1538617

> > 2009-06-28 18:54:05 0.2606429

> > 2009-06-28 18:54:06 0.6148270

> > x1

> > 2009-06-28 18:54:02 -0.8920901

> > 2009-06-28 18:54:03 0.8773917

> > 2009-06-28 18:54:04 1.2920259

> > 2009-06-28 18:54:05 -0.4256368

> > 2009-06-28 18:54:06 -0.7822110

> >

> > # x1 output should be x3 and the second x1 output should be x2

> >

> > # Let's try it as a just a data.frame as opposed to xts and see what  
> happens:

> > TimeIndex
> > BartSimpson
> > #xtsBartSimpson
> > QuestionableHeaderName1
> > BartSimpson$x2, BartSimpson$x3); QuestionableHeaderName1

> > QuestionableHeaderName2
> > BartSimpson$x2, BartSimpson$x3); QuestionableHeaderName2

> >

> > x1 x2 x3

> > 1 0.09949459 -0.01799246 1.39811684

> > 2 0.61831865 0.93604736 0.87330695

> > 3 1.26746389 1.13709153 -0.02954153

> > 4 -1.32262513 -0.09825617 -0.97914918

> > 5 -1.83912138 0.44640603 0.89351793

> > [1] -0.01799246 0.93604736 1.13709153 -0.09825617 0.44640603

> > [1] 1.39811684 0.87330695 -0.02954153 -0.97914918 0.89351793

> >

> > # The difference in output between xts and data.frame is that the

> > data.frame doesn't have an output column title at all.

> >

> > _______________________________________________

> > R-SIG-Finance@stat.math.ethz.ch mailing list

> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance

> > -- Subscriber-posting only.

> > -- If you want to post, subscribe first.

> >


	[[alternative HTML version deleted]]

