Kia ora Allen

I'm not sure what you have tried or what your level of understanding is.
However, if your dataframe is:
> allen
  sp1 sp2 sp3
1   0   0   1
2   1   0   1
3   1   1   1
4   0   0   0

> str(allen)
'data.frame':   4 obs. of  3 variables:
 $ sp1: int  0 1 1 0
 $ sp2: int  0 0 1 0
 $ sp3: int  1 1 1 0

Then looking at the output from:

paste(names(allen)[as.logical(unlist(allen[2,]))], collapse='; ')

may help you. 

Hei kona ra ...

Peter Alspach

> -----Original Message-----
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of AllenL
> Sent: Thursday, 8 January 2009 7:28 a.m.
> To: r-help@r-project.org
> Subject: [R] Another newbie question
> 
> 
> Problem: 
> I have a data frame with 1s and 0s denoting presence/absence 
> of species
> (columns) for particular plot measurements (rows). What I 
> want to do is make a new column whose entries for each row is 
> a list of the column names in which a species is present (ie. 
> for row one its entry might read:
> "sp1","sp2", etc.). I've tried various functions etc. but 
> can't seem to get the syntax right/ the correct combination 
> of functions.
> Thanks in advance!
> -Allen
> 
> --
> View this message in context: 
> http://www.nabble.com/Another-newbie-question-tp21337371p21337371.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to