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

rep_along

Create vectors matching the length of a given vector


Description

These functions take the idea of seq_along() and apply it to repeating values.

Usage

rep_along(along, x)

rep_named(names, x)

Arguments

along

Vector whose length determine how many times x is repeated.

x

Values to repeat.

names

Names for the new vector. The length of names determines how many times x is repeated.

See Also

new-vector

Examples

x <- 0:5
rep_along(x, 1:2)
rep_along(x, 1)

# Create fresh vectors by repeating missing values:
rep_along(x, na_int)
rep_along(x, na_chr)

# rep_named() repeats a value along a names vectors
rep_named(c("foo", "bar"), list(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.