Colon {base} | R Documentation |

## Colon Operator

### Description

Generate regular sequences.

### Usage

from:to
a:b

### Arguments

`from` |
starting value of sequence. |

`to` |
(maximal) end value of the sequence. |

`a, b` |
`factor` s of same length. |

### Details

The binary operator `:`

has two meanings: for factors `a:b`

is
equivalent to `interaction(a, b)`

(but the levels are
ordered and labelled differently).

For numeric arguments `from:to`

is equivalent to `seq(from, to)`

,
and generates a sequence from `from`

to `to`

in steps of `1`

or `1-`

. Value `to`

will be included if it differs from
`from`

by an integer up to a numeric fuzz of about `1e-7`

.

### Value

For numeric arguments, a numeric vector. This will be of type
`integer`

if `from`

and `to`

are both integers
and representable in the integer type, otherwise of type
`numeric`

.

For factors, an unordered factor with levels labelled as `la:lb`

and ordered lexicographically (that is, `lb`

varies fastest).

### References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
*The New S Language*.
Wadsworth & Brooks/Cole.

(for numeric arguments: S does not have `:`

for factors.)

### See Also

`seq`

.

As an alternative to using `:`

for factors, `interaction`

.

For `:`

used in the formal representation of an interaction, see
`formula`

.

### Examples

1:4
pi:6 # real
6:pi # integer
f1 <- gl(2,3); f1
f2 <- gl(3,2); f2
f1:f2 # a factor, the "cross" f1 x f2

[Package

*base* version 2.5.0

Index]