Skip to content
Prev 257787 / 398502 Next

Convert a presence/ absence matrix to a list of presence only

try this; added an extra row so that the lengths would not be even:
+ spcs1   1       1       0
+ spcs2   1       0       1
+ spcs3   0       1       1
+ spcs4   0       0       1"), header = TRUE)
spl_A spl_B spl_C
spcs1     1     1     0
spcs2     1     0     1
spcs3     0     1     1
spcs4     0     0     1
+     sp <- row.names(x)[.col == 1]
+     c(sp, rep("", maxLen - length(sp)))
+ })
spl_A   spl_B   spl_C
[1,] "spcs1" "spcs1" "spcs2"
[2,] "spcs2" "spcs3" "spcs3"
[3,] ""      ""      "spcs4"

        
On Fri, Apr 22, 2011 at 2:10 PM, antu <ananta.acharya at gmail.com> wrote: