[Rd] seq() documentation bug (PR#2590)

oehl_list@gmx.de oehl_list@gmx.de
Fri Feb 28 13:41:03 2003


The documentation of seq() states that any one-parameter call to
seq(one.parameter) is interpreted as an along= parameter. Hoewever, if one.parameter is
a vector of length 1, one.parameter is obviously interpreted as a length=
argument, see example below. This behaviour probably cannot be changed and is
the same with the prototype, however, the exception should be documented at
least.

\note{ Attention: if seq is called with one unnamed parameter like in
\code{seq(a)} AND the parameter is a vector of length 1, this parameter will NOT be
interpreted as an along= argument but as an length= argument. Try \code{for
(len in 0:10)print(seq(seq(20, length=len)))} to see this exception and
\code{for (len in 0:10)print(seq(along=seq(20, length=len)))} to avoid the
exception. As a consequence, programmers are encouraged to always name a single
parameter as in \code{seq(along=a)} }


Best


Jens Oehlschlägel


>  for (len in 0:10)print(seq(seq(20, length=len)))
numeric(0)
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
[1] 1 2
[1] 1 2 3
[1] 1 2 3 4
[1] 1 2 3 4 5
[1] 1 2 3 4 5 6
[1] 1 2 3 4 5 6 7
[1] 1 2 3 4 5 6 7 8
[1] 1 2 3 4 5 6 7 8 9
 [1]  1  2  3  4  5  6  7  8  9 10
>  for (len in 0:10)print(seq(along=seq(20, length=len)))
numeric(0)
[1] 1
[1] 1 2
[1] 1 2 3
[1] 1 2 3 4
[1] 1 2 3 4 5
[1] 1 2 3 4 5 6
[1] 1 2 3 4 5 6 7
[1] 1 2 3 4 5 6 7 8
[1] 1 2 3 4 5 6 7 8 9
 [1]  1  2  3  4  5  6  7  8  9 10


> version
         _              
platform i386-pc-mingw32
arch     i386           
os       mingw32        
system   i386, mingw32  
status                  
major    1              
minor    6.2            
year     2003           
month    01             
day      10             
language R



-- 

Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!