> names(b) <- a
A B C D E
"Tom" "Dick" "Harry" "Bob" "Joe"
Then subset by names:
E D B
"Joe" "Bob" "Dick"
> I have three vectors as follows:
>> a <- c('A','B','C','D','E')
>> b <- c('Tom','Dick','Harry','Bob','Joe')
>> d <- c('E','D','B')
> Subsetting b by using d on a, with b[a %in% d], gives the names in the order they appear in b:
>> b[a %in% d]
>>  "Dick" "Bob" "Joe"
> But I'd like them to show in the order in d, as "Joe" "Bob" "Dick". What is the easy way to do this?
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024