INTS {bimets}R Documentation

Create Range of Indexes

Description

A command such INTS(i,j) returns a one-dimensional array built with the integers i, i+1, i+2, ..., j when i, j are both scalars, and j is greater than i. When j is less than i, the command shown above defines a one-dimensional array built with the integers i, i-1, i-2, ..., j.

Users can specify the k increment with a syntax like INTS(i, j, k) which defines a one-dimensional array built with the values i, i+k, i+2*k, ..., i+N*k.

The value of the last element of the array is the maximum value of i+N*k that is less than or equal to j, for positive k. For negative k, the value of the last element of the array is the minimum value of i+N*k that is greater than or equal to j.

The command can be used with one parameter by using a syntax like INTS(i) where i is a positive scalar. The result is a one-dimensional array built with the integers 1, 2, 3, ..., i. When i is less than 1, the array is built with the integers -1, -2, ..., -i.

Usage

INTS(FROM=NULL, TO=NULL, BY=NULL, ...)

Arguments

FROM

The first integer of the sequence. If arguments TO and BY are NULL and FROM>0 the sequence will start from 1 and will end in FROM; If arguments TO and BY are NULL and FROM<0 the sequence will start from -1 and will end in FROM (see examples).

TO

The last integer of the sequence.

BY

Increment between two elements of the sequence.

...

Backward compatibility.

Value

This function returns an object of class c().

See Also

TSJOIN
TSEXTEND
TSMERGE
MOVAVG
GETYEARPERIOD
TSLAG
TSINFO
TABIT
ELIMELS

Examples

	
	print(INTS(10,1,-2)) #... 10  8  6  4  2
	
	#...Error in INTS(10, 1, -0.5) : INTS(): inputs must be integers.
	tryCatch({print(INTS(10,1,-0.5));},error=function(e){cat(e$message)})
	
	print(INTS(10))  #...  1  2  3  4  5  6  7  8  9 10
	print(INTS(-10)) #  -1  -2  -3  -4  -5  -6  -7  -8  -9 -10
	
	# Error in INTS(0) : INTS(): magnitude must be >=1
	tryCatch({print(INTS(0));},error=function(e){cat(e$message)})
	
	print(INTS(-10,-45)) # -10 -11 -12 ... -41 -42 -43 -44 -45
	
	#...Error in seq.default(FROM, TO, BY) : wrong sign in 'by' argument
	tryCatch({print(INTS(-10,-45,3));},error=function(e){cat(e$message)})
	
	print(INTS(-10,-45,-3)) # -10 -13 -16 -19 -22 -25 -28 -31 -34 -37 -40 -43

[Package bimets version 1.5.3 Index]