[R] Split an array into arbirtary sizes

R. Michael Weylandt michael.weylandt at gmail.com
Sat Oct 29 14:40:56 CEST 2011

The short answer is that you need to use the window() command with ts objects.

The (ever so slightly) longer answer is that no one really likes ts
objects and that's why a proliferation of contributed packages exist
to deal with their "idiosyncracies". The most popular for finance are
zoo and xts and I heartily recommend you start using those for your
analysis if at all possible. If you use those, you can use simple
commands like x[1:250] to get the first 250 elements or you can subset
by time for xts which is very nice.


On Fri, Oct 28, 2011 at 6:59 PM, Bazman76 <h_a_patience at hotmail.com> wrote:
> sorry!
> vols=read.csv(file="C:/Documents and Settings/Hugh/My
> Documents/PhD/Quick&DirtyVols.csv"
> +  , header=TRUE, sep=",")
>> x<-ts(vols[,2])
>> x
> so I have an ts object of 500 elements.
> I want to be able to split the array into say two parts of 250?
> How can I do it?
> I want to keep the elements in the same order
> --
> View this message in context: http://r.789695.n4.nabble.com/Split-an-array-into-arbirtary-sizes-tp3948938p3949426.html
> Sent from the R help mailing list archive at Nabble.com.
> ______________________________________________
> 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.

More information about the R-help mailing list