seq( )

Generate sequences of numbers. seq() is a base R function.

Required Library

# seq() is part of base R — no package installation needed

Syntax

seq(from, to)
seq(from, to, by = step)
seq(from, to, length.out = n)

seq() creates a numeric sequence from a start value to an end value. You can control the spacing with by, or request a fixed number of values with length.out.

Use seq() whenever you need evenly spaced numeric values. Common uses include time vectors, concentration grids, and x-values for plotting smooth curves.

The : operator is quick for simple integer steps like 1:10. Use seq() when you need decimal steps, a fixed output length, or descending sequences with custom step size.

Examples

Create a basic integer sequence
Set a custom step size with by
Generate a fixed number of values with length.out
Create a descending sequence

Argument Overview

Required arguments must be included when using a function while optional arguments can be included on demand.

from — start value numeric Required

The first value in the sequence.

seq(from = 0, to = 1, by = 0.2)

Data Types: numeric

to — end value numeric Required

The target end value of the sequence.

Data Types: numeric

by — step size numeric Optional

Difference between consecutive values. Use a negative value for descending sequences.

seq(10, 0, by = -2)

Data Types: numeric

length.out — number of output values integer Optional

Creates exactly this many values between from and to.

seq(0, 1, length.out = 6)

Data Types: integer