[R] inserting elements in a list
j+rhelp at howard.fm
Tue Feb 18 21:36:03 CET 2003
On Tue, 18 Feb 2003 07:47:56 -0800 (PST), "Thomas Lumley"
<tlumley at u.washington.edu> said:
> threes<- a==3
> offset<- c(0,cumsum(threes)[-N])
> On Tue, 18 Feb 2003 j+rhelp at howard.fm wrote:
> > The problem is that it is placing the '7's in the correct place, but is
> > not shifting the right-hand side of the list across to make room.
> The code does work, but you have to use all of it, not just that line.
> The *previous* line does the shifting.
D'oh! Of course!
Now that *is* a clever solution. :-)
jhoward at fastmail.fm
More information about the R-help