function in R Language is used to create a sequence of elements in a Vector. It takes the length and difference between values as optional argument.**seq()**

Syntax:

seq(from, to, by, length.out)

Parameters:

from:Starting element of the sequence

to:Ending element of the sequence

by:Difference between the elements

length.out:Maximum length of the vector

**Example 1:**

`# R Program to illustrate ` `# the use of seq() Function ` ` ` `# Creating vector using seq() ` `vec1 <` `-` `seq(` `1` `, ` `10` `, by ` `=` `2` `) ` ` ` `vec2 <` `-` `seq(` `1` `, ` `10` `, length.out ` `=` `7` `) ` ` ` `# Printing vectors ` `print` `(vec1) ` `print` `(vec2) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 1 3 5 7 9 [1] 1.0 2.5 4.0 5.5 7.0 8.5 10.0

**Example 2:**

`# R Program to illustrate ` `# the use of seq() Function ` ` ` `# Creating vector using seq() ` `vec1 <` `-` `seq(` `10` `, ` `1` `, by ` `=` `-` `2` `) ` ` ` `vec2 <` `-` `seq(` `10` `, ` `1` `, length.out ` `=` `4` `) ` ` ` `# Printing vectors ` `print` `(vec1) ` `print` `(vec2) ` |

*chevron_right*

*filter_none*

**Output:**

[1] 10 8 6 4 2 [1] 10 7 4 1

## Recommended Posts:

- Generating sequenced Vectors in R Programming - sequence() Function
- Get a List of Numbers in the Specified Range in R Programming - seq.int() Function
- Convert an Object into a Vector in R Programming - as.vector() Function
- Check for the Existence of a Vector Object in R Programming - is.vector() Function
- Create a Vector of Colors from a Vector of Gray Levels in R Programming - gray() or grey() Function
- Add Leading Zeros to the Elements of a Vector in R Programming - Using paste0() and sprintf() Function
- Check if Elements of a Vector are non-empty Strings in R Programming - nzchar() Function
- Make Elements of a Vector Unique in R Programming - make.unique() Function
- Replace the Elements of a Vector in R Programming - replace() Function
- Check if the elements of a Vector are Finite, Infinite or NaN values in R Programming - is.finite(), is.infinite() and is.nan() Function
- Calculate the difference between Consecutive pair of Elements of a Vector in R Programming - diff() Function
- Calculate Median of elements of a Vector in R Programming - median() Function
- Get the Sign of Elements of a Numeric Vector in R Programming - sign() Function
- Creating 3D Plots in R Programming - persp() Function
- Replicate elements of vector in R programming - rep() Method
- Adding elements in a vector in R programming - append() method
- Compute the gamma value of a Non-negative Numeric Vector in R Programming - gamma() Function
- Check if values in a vector are True or not in R Programming - all() and any() Function
- Getting Match of an Element within a Vector in R Programming - charmatch() Function
- Extracting Substrings from a Character Vector in R Programming - substring() Function

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.