Skip to content
Prev 3449 / 7420 Next

removing singleton taxa

Hi Kate,

This is pretty terse, but try

df2 <- df1[,apply( df1, 2, function(x) sum( x>0)) > 1]

This subsets the columns of df1 to those that have more than 1 presence.

You may want to have a look at ?apply to see how it works.

Good luck,

Scott

PS  There are many ways to skin this cat.  For example, you could look 
at colSums( df1>0), for example.  This would do exactly the same thing 
as the apply() in the above.
On 18/12/12 11:22, Kate Boersma wrote: