R - Colon (:) Operator - Sequence generator
Table of Contents
1 - About
2 - Articles Related
Advertising
3 - 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.
4 - Example
4.1 - Integer Sequence
> 1:4 [1] 1 2 3 4 > 6:pi [1] 6 5 4
4.2 - Real Sequence
> pi:6 [1] 3.141593 4.141593 5.141593
4.3 - "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
5 - Documentation / Reference
?":" help(":")
Advertising