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

vector.namesmatch

reorder vector v into order determined by matching the names of its elements to a vector of names


Description

A helper function to reorder vector v (if named) into order specified by matching its names to the argument names

Usage

vector.namesmatch(v, names, errname = NULL)

Arguments

v

a vector (or list) with named elements, to be reorderd

names

a character vector of element names, corresponding to names of v, specificying desired orering of v

errname

optional, name to be reported in any error messages. default to deparse(substitute(v))

Details

does some checking of appropriateness of arguments, and reorders v by matching its names to character vector names

Value

returns v, with elements reordered

Note

earlier versions of this function did not order as advertiased

Examples

test<-list(c=1,b=2,a=3)
vector.namesmatch(test,names=c('a','c','b'))

statnet.common

Common R Scripts and Utilities Used by the Statnet Project Software

v4.4.1
GPL-3 + file LICENSE
Authors
Pavel N. Krivitsky [aut, cre] (<https://orcid.org/0000-0002-9101-3362>), Skye Bender-deMoll [ctb]
Initial release
2020-10-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.