Learn R Programming

searchable (version 0.3.3.1)

invert: Invert a structure by swapping keys and values

Description

Invert a structure by swapping keys and values

Usage

invert(x)

## S3 method for class 'vector': invert(x)

## S3 method for class 'Searchable': invert(x)

## S3 method for class 'list': invert(x)

Arguments

x
object to invert

Value

  • A character vector in which the names are the former valeus.

Details

Inverts named vectors

Examples

Run this code
v <- 1:26
 names(v) <- letters

 invert(v)

 l <- as.list(v)

Run the code above in your browser using DataLab