Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

seq2

Increasing sequence of integers in an interval


Description

These helpers take two endpoints and return the sequence of all integers within that interval. For seq2_along(), the upper endpoint is taken from the length of a vector. Unlike base::seq(), they return an empty vector if the starting point is a larger integer than the end point.

Usage

seq2(from, to)

seq2_along(from, x)

Arguments

from

The starting point of the sequence.

to

The end point.

x

A vector whose length is the end point.

Value

An integer vector containing a strictly increasing sequence.

Examples

seq2(2, 10)
seq2(10, 2)
seq(10, 2)

seq2_along(10, letters)

rlang

Functions for Base Types and Core R and 'Tidyverse' Features

v0.4.11
MIT + file LICENSE
Authors
Lionel Henry [aut, cre], Hadley Wickham [aut], mikefc [cph] (Hash implementation based on Mike's xxhashlite), Yann Collet [cph] (Author of the embedded xxHash library), RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.