Table of Contents

About

The Colon (:) Operator generate regular sequences.

Usage

from:to  # sequence
a:b      # cross of factor

where:

  • from, starting value of sequence and to: (maximal) end value of the sequence.
  • a, b factors of the same length.

Example

Integer Sequence

> 1:4
[1] 1 2 3 4
> 6:pi
[1] 6 5 4

Real Sequence

> pi:6
[1] 3.141593 4.141593 5.141593

“cross” factor

> f1 <- gl(2, 3); f1
[1] 1 1 1 2 2 2
Levels: 1 2
> f2 <- gl(3, 2); f2
[1] 1 1 2 2 3 3
Levels: 1 2 3
> f1:f2 # a factor, the "cross"  f1 x f2
[1] 1:1 1:1 1:2 2:2 2:3 2:3
Levels: 1:1 1:2 1:3 2:1 2:2 2:3

Documentation / Reference

?":"
help(":")