Learn R Programming

str2str (version 1.0.0)

sn: Set a Vector's Names as its Elements

Description

sn sets a vector's names as its elements. It is a simple utility function equal to setNames(x, nm = as.character(x)). This is particularly useful when using lapply and you want the return object to have X as its names.

Usage

sn(x)

Value

x with the elements of x as its names.

Arguments

x

atomic or list vector.

Examples

Run this code
sn(1:10)
sn(c("one","two","three"))

Run the code above in your browser using DataLab