[Rd] Patch to allow negative argument in head() and tail()

François Pinard pinard at iro.umontreal.ca
Tue Jul 18 23:41:53 CEST 2006


[Vincent Goulet]

>For me, this usage of head() and tail() is, at first, completely 
>unintuitive since I more used to, say, "start from the beginning (head) 
>of the vector and drop the first n elements" than "return the end of 
>the vector except the first n elements". But I must agree your 
>convention does make sense!

Vincent -- bonjour!, Martin -- hi! and all others -- hello! :-)

The usual head and tail Unix utilities, as found within GNU Coreutils,
have conventions for negative numbers.  See:

  $ seq 10 | head -n-3
  1
  2
  3
  4
  5
  6
  7
  $ seq 10 | tail -n-3
  8
  9
  10
  $

Of course, these do not rule what R should do in any way.  Yet, it is 
sometimes convenient and even elegant when tools having similar names 
have similar behaviour.  Despite application domains are different, it's 
worth pondering such similarities, when these are easily possible.

-- 
François Pinard   http://pinard.progiciels-bpi.ca



More information about the R-devel mailing list