Open In App
Related Articles

Generate a Sequence of Length of the passed Argument in R Programming – seq_along() Function

Improve Article
Improve
Save Article
Save
Like Article
Like

seq_along() function in R Language is used to generate a sequence of the same length of the argument passed.

Syntax: seq_along(x)

Parameters:
x: specified arguments

Example 1:




# R program to illustrate
# seq_along function
  
# Calling the seq_along() function
seq_along(letters[1:4])
seq_along(letters[0:3])


Output:

[1] 1 2 3 4
[1] 1 2 3

Example 2:




# R program to illustrate
# seq_along function
  
# Calling the seq_along() function
seq_along(c(1, 2, 3))
seq_along(c(5, 10, 15, 20))
seq_along(c(2, 4))
seq_along(10)
seq_along(2)


Output:

[1] 1 2 3
[1] 1 2 3 4
[1] 1 2
[1] 1
[1] 1
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 24 Jun, 2020
Like Article
Save Article
Previous
Next
Similar Reads