[R] Data frame transpose

Kang.Daiwen@epamail.epa.gov Kang.Daiwen at epamail.epa.gov
Mon Sep 29 19:15:36 CEST 2003





Hi All,

I want to ask if there is a transpose function for data frame like the
procedure of transpose in SAS? Because I want to partially transpose a
data frame which contains 5 columns (siteid, date, time, obs, mod), what
I want to do is to put time as the column variables along with siteid,
and date, and put obs and mod in the row names. specifically to
transpose a data frame:

siteid     date    time   obs     mod
    A       7/8        01       2         5
    A       7/8        02        3        8
    A       7/8        03        5        8
     A       7/9       01       3          6
   A         7/9      02        5          8
   A         7/9       03       6           7
                       ......
   B         7/8      01          4         7
    B        7/8      02        7        19
   B         7/8     03         4        9
                      ......

To

siteid    date    name     01    02     03   ....
A              7/8       obs       2      3        5
A              7/8       mod      5      8        8
A              7/9       obs       3      5         6
A              7/9       mod      6      8        7
                 .......
B              7/8        obs       4      7        4
B              7/8        mod      7      19      9
                ........


Thank you very much!

Dave




More information about the R-help mailing list