How to Apply the seq() Function in R (5 Examples)

In this tutorial you’ll learn how to apply the seq function in the R programming language.

Example 1: How to Apply the seq() Function in R

seq(4)                           # Basic application of seq() function
# 1 2 3 4

Example 2: Changing Starting Point of Sequence

seq(2, 4)                        # Change starting point
# 2 3 4

Example 3: Changing Increment of Sequence

seq(2, 4, 0.33)                  # Using by argument
# 2.00 2.33 2.66 2.99 3.32 3.65 3.98

Example 4: Changing Length of Sequence Using length.out Argument

seq(2, 4, length.out = 10)       # Using length.out argument
# 2.000000 2.222222 2.444444 2.666667 2.888889 3.111111 3.333333 3.555556 3.777778 4.000000

Example 5: Changing Length of Sequence Using along.with Argument

seq(3, 10, along.with = 1:10)    # Using along.with argument
# 2.000000 2.222222 2.444444 2.666667 2.888889 3.111111 3.333333 3.555556 3.777778 4.000000

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top