Learn R Programming

SSBtools (version 1.7.0)

matlabColon: Simulate Matlab's ':'

Description

Functions to generate increasing sequences

Usage

matlabColon(from, to)

SeqInc(from, to)

Value

A numeric vector, possibly empty.

Arguments

from

numeric. The start value

to

numeric. The end value.

Author

Bjørn-Helge Mevik (matlabColon) and Øyvind Langsrud (SeqInc)

Details

matlabColon(a,b) returns a:b (R's version) unless a > b, in which case it returns integer(0). SeqInc(a,b) is similar, but results in error when the calculated length of the sequence (1+to-from) is negative.

See Also

Examples

Run this code
identical(3:5, matlabColon(3, 5)) ## => TRUE
3:1 ## => 3 2 1
matlabColon(3, 1) ## => integer(0)
try(SeqInc(3, 1)) ## => Error
SeqInc(3, 2)      ## => integer(0)

Run the code above in your browser using DataLab