Dear R-helpers, I have a question about giving index. Suppose that I have a vector say, id=1:5, and each of them have some given index but some of them may share the same index Now, I have another vector, and I want to give it a index based what just defined. # 5 subjects test1=1:5 # corresponding index, so here, subject 2 and subject 4 share the common index "1" index=c(3,1,2,1,4) # now I have another vector, and I want to use the index defined above test2=c(5,4,2,1,1,5,3) ## so, the result should be something like this--index of test2 is (4,1,1,3,3,4,2) How can I program this ? Any help will be highly appreciated. Thank you all, Carrie [[alternative HTML version deleted]]
Dear R-helpers, I have a question about giving index. Suppose that I have a vector say, id=1:5, and each of them have some given index but some of them may share the same index Now, I have another vector, and I want to give it a index based what just defined. # 5 subjects test1=1:5 # corresponding index, so here, subject 2 and subject 4 share the common index "1" index=c(3,1,2,1,4) # now I have another vector, and I want to use the index defined above test2=c(5,4,2,1,1,5,3) ## so, the result should be something like this--index of test2 is (4,1,1,3,3,4,2) How can I program this ? Any help will be highly appreciated. Thank you all, Carrie [[alternative HTML version deleted]]
Dear R-helpers, I have a question about giving index. Suppose that I have a vector say, id=1:5, and each of them have some given index but some of them may share the same index Now, I have another vector, and I want to give it a index based what just defined. # 5 subjects test1=1:5 # corresponding index, so here, subject 2 and subject 4 share the common index "1" index=c(3,1,2,1,4) # now I have another vector, and I want to use the index defined above test2=c(5,4,2,1,1,5,3) ## so, the result should be something like this--index of test2 is (4,1,1,3,3,4,2) How can I program this ? Any help will be highly appreciated. Thank you all, Carrie [[alternative HTML version deleted]]
On Jan 21, 2010, at 1:18 AM, Carrie Li wrote:> Dear R-helpers, > I have a question about giving index. > Suppose that I have a vector say, id=1:5, and each of them have some > given > index but some of them may share the same index > Now, I have another vector, and I want to give it a index based what > just > defined. > > # 5 subjects > test1=1:5 > # corresponding index, so here, subject 2 and subject 4 share the > common > index "1" > index=c(3,1,2,1,4) > > # now I have another vector, and I want to use the index defined above > test2=c(5,4,2,1,1,5,3) > > ## so, the result should be something like this--index of test2 is > (4,1,1,3,3,4,2)> index[test2] [1] 4 1 1 3 3 4 2>-- David Winsemius, MD Heritage Laboratories West Hartford, CT