From vincent.goulet at act.ulaval.ca  Wed Apr 20 20:26:24 2005
From: vincent.goulet at act.ulaval.ca (Vincent Goulet)
Date: Wed Apr 20 20:26:40 2005
Subject: [Rd] Negative argument for head() and tail()
Message-ID: <200504201426.24523.vincent.goulet@act.ulaval.ca>

Dear R developers,

I'm a former APL programmer. In that language, the "take" (up arrow) and 
"drop" (down arrow) operators were extensively used to, well, take and drop 
elements of vectors. Functions head() and tail() are equivalents in R for the 
"take" operator, but nothing seems to mimic the "drop" operator. I think it 
would be useful.

For example, is there any simpler way to extract all elements of a vector but 
the last one than doing

> x[1:(length(x) - 1)]  ?

An equivalent of "drop" would make this easy.

Now, I think this could be easily implemented with the existing functions by 
allowing negative arguments to head() and tail(). For example, 

> head(x, -1)

would drop the first element of a vector and

> tail(x, -length(x))

the last one.

Is there any interest for such an extension?

I would be very willing to contribute a patch, although I don't have much 
experience in doing so.

Best regards,

-- 
  Vincent Goulet, Associate Professor
  ?cole d'actuariat
  Universit? Laval, Qu?bec 
  Vincent.Goulet@act.ulaval.ca   http://vgoulet.act.ulaval.ca


[Rd] Negative argument for head() and tail()
Vincent Goulet