The function seq is a widely used function to generate a sequence. from
, to
, by
, and length.out
are widely used arguments in seq function.
The basic usage of seq function is written in the exercise.
# Generate a sequence from 1 to 10 by using seq function
seq(from = 1, to = 10)
seq(1, 10)
seq(10)
# Alternative way to make 1 to 10 sequence
1:10
# Generate a sequence of odd numbers from 1 to 100 by using seq function
seq(from = 1, to = 100, by = 2)
seq(1, 100, 2)
# Generate a sequence of even numbers within 1 to 100 by using seq function
seq(1, 100, 2) + 1
seq(2, 100, 2)
2 * seq(1, 50)