Learn R Programming

doofa (version 1.0)

swap: swap elements at i and i+1 of a vector

Description

swap elements at i and i+1 of a vector

Usage

swap(x, i)

Value

a vector with swapped elements

Arguments

x

a vector

i

a positive integer, less than length of x

Examples

Run this code
swap(c(1,2,3),2);

Run the code above in your browser using DataLab