[R-SIG-Finance] multiple columns with time series dates

R. Michael Weylandt michael.weylandt at gmail.com
Fri Jun 8 21:08:12 CEST 2012


Untested [because I'm not quite sure what you mean about the date
discrepancy -- I don't see it], I'd try something like this:

xts(t.r[, c(FALSE,TRUE,TRUE)], t.r[,1])

You might need to adjust some factors to dates depending on what
read.csv did with them.

Best,
Michael

On Thu, Jun 7, 2012 at 4:30 AM, tonyp <petrovaa at gmail.com> wrote:
> Hi folks,
>
> I have data that I read in from excel. It is a multivariate asset classes
> download i.e. not equal time lengths.
> So it is still a data frame. It looks something like that:
>
> t.r<-read.csv('momdata.csv',header=T, fill=T)  #read table
>
>        Date   UKX.P        UKX.R     Date.1   SMI.P        SMI.R     Date.2
> 1 07/05/2009 4398.68           NA 07/05/2009 5325.63           NA 07/05/2009
> 2 08/05/2009 4462.09  0.014415688 08/05/2009 5391.01  0.012276482 08/05/2009
> 3 11/05/2009 4435.50 -0.005959091 11/05/2009 5358.94 -0.005948793 11/05/2009
> 4 12/05/2009 4425.54 -0.002245519 12/05/2009 5346.03 -0.002409059 12/05/2009
> 5 13/05/2009 4331.37 -0.021278759 13/05/2009 5277.37 -0.012843175 13/05/2009
> 6 14/05/2009 4362.58  0.007205572 14/05/2009 5360.00  0.015657420 14/05/2009
>   SX5E.P       SX5E.R     Date.3 FTSEMIB.P    FTSEMIB.R     Date.4  RTY.P
> 1 2406.08           NA 07/05/2009  19814.21           NA 07/05/2009 492.94
> 2 2462.39  0.023403212 08/05/2009  20508.55  0.035042528 08/05/2009 511.82
> 3 2433.59 -0.011695954 11/05/2009  20200.28 -0.015031292 11/05/2009 501.94
> 4 2424.34 -0.003800969 12/05/2009  20337.15  0.006775649 12/05/2009 495.18
> 5 2357.30 -0.027652887 13/05/2009  19380.88 -0.047020846 13/05/2009 471.82
> 6 2353.53 -0.001599287 14/05/2009  19271.42 -0.005647834 14/05/2009 480.71
>        RTY.R     Date.5  OMX.P       OMX.R     Date.6   NDX.P        NDX.R
> 1          NA 07/05/2009 792.47          NA 07/05/2009 1389.83           NA
> 2  0.03830081 08/05/2009 802.03  0.01206355 08/05/2009 1394.16  0.003115489
> 3 -0.01930366 11/05/2009 783.38 -0.02325349 11/05/2009 1395.79  0.001169163
> 4 -0.01346774 12/05/2009 769.34 -0.01792234 12/05/2009 1377.40 -0.013175334
> 5 -0.04717477 13/05/2009 748.10 -0.02760808 13/05/2009 1339.83 -0.027276027
> 6  0.01884193 14/05/2009 757.66  0.01277904 14/05/2009 1359.67  0.014807849
>
>
> I am trying to combine all these assets in one xts object aligned based on a
> first date (because there is a discrepancy between dates). How do I do that?
> If you can help, I would totally appreciate it. Thanks in advance, you quant
> wizards.
>
> Best of luck.
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/multiple-columns-with-time-series-dates-tp4632660.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list