[R] time series - cbind
Joe Stuart
joe.stuart at gmail.com
Fri Oct 28 17:52:01 CEST 2011
I will. Thanks
On Fri, Oct 28, 2011 at 10:18 AM, David Winsemius
<dwinsemius at comcast.net> wrote:
>
> On Oct 28, 2011, at 10:32 AM, Joe Stuart wrote:
>
>> Hi,
>> I have a time series ts.score that gets created based on a function.
>> When I print the time series out it prints two rows, first the date
>> then the value.
>>
>> 2011-06-14
>> -1.25947868
>>
>> The function gets called multiple times in my script and I'm trying to
>> append the time series to an object called ts.bind using the cbind
>> function like so. The only problem I have is that the date is an index
>> for all of the columns, which is only correct for the first column. Is
>> there a way that I can associate the correct dates with each column?
>
> You should look at the 'zoo' package. It supplies merge and cbind methods
> for its zoo-class objects that will properly align values by their index.
> Many people have experienced the problems you are currently seeing and ....
> "zoo" is the solution.
>
>>
>> ts.bind <- cbind(ts.bind, ts.score)
>>
>> ts.score ts.score ts.score
>> ts.score ts.score
>> 2010-10-14 1.06493449 0.96323675 1.13255734 -0.3060238
>> 1.0083540
>> 2010-10-15 0.51371978 -0.54348798 0.82563515 -0.8808261
>> 0.9578659
>> 2010-10-18 0.03667826 0.25904910 0.56100008 -1.0084433
>> 0.5220185
>> 2010-10-19 -2.32490163 0.08469947 0.09021838 -1.7677688
>> 0.7954248
>> 2010-10-20 -1.52627229 0.15408516 0.16440753 -1.4923426
>> 0.5221617
>>
>> I appreciate any help.
>>
>> ______________________________________________
>> 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.
>
> David Winsemius, MD
> West Hartford, CT
>
>
More information about the R-help
mailing list