Learn R Programming

turner (version 0.1.9)

indexify: Create indices for elements in a vector or list

Description

Create indexed components for the elements of a list.

Usage

indexify(x, out)

Value

A vector (or list) of indexed numbers

Arguments

x

a numeric vector or list of vectors

out

string indicating the output format ("vector" or "list")

Author

Gaston Sanchez

See Also

listify

Examples

Run this code
# let's say you have a numeric vector like this
num_vec = c(2, 3, 1, 4)

# get indices in vector format
indexify(num_vec)

# let's say you have a list like this
str_list = list(c("a","b","c"), c("d", "e"), c("f","g","h"))

# get indices in vector format
indexify(str_list)

# get indices in list format
indexify(str_list, "list")

Run the code above in your browser using DataLab