# R - Colon (:) Operator - Sequence generator

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(":")```
```

Discover More
R - (Mathematical|Logical) Operators

& boolean and | boolean for xor exactly or ! not any any true all all true Not (!) Many operations in R are vectorized. < Less than > Greater than == Equal to <= Less than or equal...
R - Data Generator

R - Data frame Object

A data frame is a logical implementation of a table in a relational database A data frame inherits all the property and function of an object. It has a list of variables of the same number of rows with...
R - Integer

The integer class Numeric format is the default number system. If you explicitly want an integer, you need to specify it with the Lsuffix. When using the combine function, integer must be also...
R - Special Character

R - Special Character