Generating sequenced Vectors in R Programming – sequence() Function

function in R Language is used to create a vector of sequenced elements. It creates vectors with specified length, and specified differences between elements. It is similar to seq() function.**sequence()**

Syntax:sequence(x)

Parameters:x:Maximum element of vector

**Example 1:**

`# R program to create sequence of vectors` ` ` `# Calling sequence() function` `sequence(` `4` `)` `sequence(` `6` `)` `sequence(c(` `4` `, ` `6` `))` |

**Output:**

[1] 1 2 3 4 [1] 1 2 3 4 5 6 [1] 1 2 3 4 1 2 3 4 5 6

**Example 2:**

`# R program to create sequence of vectors` ` ` `# Calling sequence() function` `sequence(` `1` `:` `4` `)` ` ` `# Performing operations` `x <` `-` `2` `*` `sequence(` `4` `)` `x` |

**Output:**

[1] 1 1 2 1 2 3 1 2 3 4 [1] 2 4 6 8