Skip to content
Back to formatted view

Raw Message

Message-ID: <cnvlod$q4c$1@sea.gmane.org>
Date: 2004-11-23T15:40:59Z
From: Henrik Andersson
Subject: Create a vector of  combinations based on a table column names

I want to create a character vector based on the table (shortened for 
display) below:
Where there are ones in the matrix I want the column name to appear and 
where there are zeros nothing, which would make the vector in this 
shortened case:

combinations <- ("A B","A C","A E H","A F G","B C D","E G H",A C D E 
H","A C D F G")

     no  value  A  B  C  D  E  F  G   H
1    2  3.095  1  1  0  0  0  0  0   0
2    2  1.687  1  0  1  0  0  0  0   0
46   3  3.470  1  0  0  0  1  0  0   1
47   3  1.563  1  0  0  0  0  1  1   0
50   3  6.234  0  1  1  1  0  0  0   0
148  4  3.663  0  0  1  0  1  0  1   1
151  4  3.470  0  0  0  1  1  1  0   1
177  5  5.411  1  0  1  1  1  0  0   1
178  5  6.829  1  0  1  1  0  1  1   0

Question is how to make this not so manually?

---------------------------------------------
Henrik Andersson
Netherlands Institute of Ecology -
Centre for Estuarine and Marine Ecology
P.O. Box 140
4400 AC Yerseke
Phone: +31 113 577473
h.andersson at nioo.knaw.nl
http://www.nioo.knaw.nl/ppages/handersson