looping: sequences for easy looping

Description Usage Arguments Details Value Examples

Description

(bc) This function returns 1:nb when nb > 0 and numeric(0) otherwise. Quite useful to prevent starting a loop of length nought
(bd) This function returns n1:n2 when n1<=n2 and numeric(0) otherwise. Quite useful when some insertion must be done within a sequence
(bf) This function returns 1:length(x) when length(x) > 0 and numeric(0) otherwise. Quite useful to prevent starting a loop of length nought

Usage

1
2
3
4
 
  bc(nb) 
  bd(n1,n2) 
  bf(x) 

Arguments

nb

length of the loop

n1

first element

n2

second element

x

vector

Details

nb is rounded before use

Value

(bc) 1:nb if nb > 0 else numeric(0).
(bd) n1:n2 if n1<n2 else numeric(0).
(bf) 1:length(x) if length(x) > 0 else numeric(0).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 
  ## 
  ## bc 
  bc(0); 
  bc(5); 
  bc(pi); 
  bc(4*pi); 
  ## 
  ## bd 
  xx <- 1:5; 
  for (ii in 1:6) { print(c(xx[bd(1,ii-1)],10,xx[bd(ii,5)]));} 
  ## 
  ## bf 
  bf(0); 
  bf(5); 
  bf(character(0)); 
  bf(letters); 

rbsa documentation built on May 2, 2019, 6:07 p.m.