[R] Spliting a huge vector
devens8765 at yahoo.com
Thu Sep 21 22:43:49 CEST 2006
Dear R users,
Sorry, I made a mistake in my specification of
problem, should be:
# my vector is this
a.vector <- seq(2, by=5, length=1000)
# so my cut values are
cut.values <- c(30, 50, 100, 109, 300, 601, 803, 1000)
# and x should have an extra ")" at the end
x <- rep(1:length(cut.values), times=diff(c(0,
Thanks for all the responses so far. Any additional
responses are welcome.
--- Dave Evens <devens8765 at yahoo.com> wrote:
> Dear R users,
> I have a huge vector that I would like to split into
> unequal slices. However, the only way I can do this
> to create another huge vector to define the groups
> that are used to split the original vector, e.g.
> # my vector is this
> a.vector <- seq(2, by=5, length=100)
> # indices where I would like to slice my vector
> cut.values <- c(30, 50, 100, 109, 300, 601, 803)
> # so I have to create another vector of similar
> # to use the split() command, i.e.
> x <- rep(1:length(cut.values), times=diff(c(0,
> # this means I can use split()
> split(a.vector, x)
> This seems to be a waste in terms of memory usage as
> I'm creating another vector (here "x") to split the
> original vector. Is there a better way to split a
> vector than this? Any help is much appreciated.
> Do You Yahoo!?
> protection around
More information about the R-help