In R, the seq()
function is used to generate a regular sequence of numbers.
seq(from, to, by)
The seq()
function takes three parameter values:
from
: This represents where the sequence should begin.to
: This represents where the sequence should end.by
: This represents the step size or interval of the sequence.The seq()
function returns a regular sequence.
# using the seq() functioneven_numbers <- seq(from = 0, to = 10, by = 2)even_numbers
seq()
function to generate a sequence of numbers, from 0
to 10
, with a step size or interval of 2
. We also assign the output of the sequence to a variable called even_numbers
.even_numbers
variable.