Hi everyone,

 

My (simplified) problem is the following one: I have two tables. The first
table contains 5 columns with 5 values and the second table contains a
single value for each vector name of the first table (see tables below):

 

Table 1:

 

A             B             C             D             E

1             2             3             4             5

2             3             4             5             6

3             4             5             6             7

4             5             6             7             8

5             6             7             8             9

 

 

Table 2:

 

A             B             C             D             E

3             5             2             1             4

 

My goal is to first sort the values of Table 2 and then use the new header
of it to sort the columns of Table 1 according to that. I already sorted
Table 2 by using the sort(Table2) function getting the following result:

 

D             C             A             E             B

1             2             3             4             5

 

How can I now sort the columns in Table 1 according to the header of the new
sorted Table 2. That is, have column D in the first position of Table 1,
column C in the second, and forth.

 

Many thanks for your assistance!

S.B.

 


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.
  • [R] Sorting data in... Samir Benzerfa

Reply via email to