s-news
[Top] [All Lists]

Transpose data without creating a list

To: s-news@wubios.wustl.edu
Subject: Transpose data without creating a list
From: Stafford Phillip-APS095 <phillip.stafford@motorola.com>
Date: Tue, 18 Sep 2001 16:21:11 -0500
Dear S group;

I'm using S+ 6 on UNIX and I have a set of data listed below:

ID                      320                     321
Set                     1758                    1758            .....and so on
Name                    BRAIN                   EYE
A1                      0.322504                0.281239
A2                      1.447151                1.591323
A3                      0.105520                0.158396
A4                      0.698740                0.754183
A5                      0.082921                0.270745
A6                      1.041902                0.981910

I wish to transpose it to a stacked format like this:

Name                    val             group   lot     name
A1                      0.322504        320     1758    BRAIN
A2                      1.447151        320     1758    BRAIN
A3                      0.105520        320     1758    BRAIN
A4                      0.698740        320     1758    BRAIN
A5                      0.082921        320     1758    BRAIN
A6                      1.041902        320     1758    BRAIN
A1                      0.281239        321     1758    EYE
A2                      1.591323        321     1758    EYE
A3                      0.158396        321     1758    EYE
A4                      0.754183        321     1758    EYE
A5                      0.270745        321     1758    EYE
A6                      0.981910        321     1758    EYE


This seemed simple at first but I have tried (unsuccessfully) to use apply, 
tapply, sapply, aperm, and solve. Any ideas, suggestions, or derision (if 
accompanied by suggestions) would be greatly appreciated.  It would be nice if 
this weren't returned as a list but rather a data.frame.

Thank you very much;

Phillip Stafford

<Prev in Thread] Current Thread [Next in Thread>
  • Transpose data without creating a list, Stafford Phillip-APS095 <=