powered by
A helper function to reorder vector v (if named) into order specified by matching its names to the argument names
v
names
vector.namesmatch(v, names, errname = NULL)
returns v, with elements reordered
a vector (or list) with named elements, to be reorderd
a character vector of element names, corresponding to names of v, specificying desired orering of v
optional, name to be reported in any error messages. default to deparse(substitute(v))
deparse(substitute(v))
does some checking of appropriateness of arguments, and reorders v by matching its names to character vector names
test<-list(c=1,b=2,a=3) vector.namesmatch(test,names=c('a','c','b'))
Run the code above in your browser using DataLab