[R] seqN

Paul Gilbert pgilbert at bank-banque-canada.ca
Tue Nov 30 18:10:07 CET 1999


 I have  been using a function

seqN <- function(N) {if (0==length(N)) NULL else if (N<=0) NULL else seq(N)}

in for loops when I want no looping in the case of a zero value:

for (i in seqN(m) ) ...

Since seqN(0) returns NULL this results in for doing no loops (which is much
more convenient than always checking for m==0). It seems that a function like
this should be defined in R (and S) but I have never found it. Is there an
already defined function that does this (or a better way to achieve this
result)?

Paul Gilbert

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list