[R-sig-eco] Converting species counts into species list

Daniel Pritchard daniel.pritchard at botany.otago.ac.nz
Mon Dec 6 09:45:56 CET 2010


Something like,

   rep(df$species, times=df$abundance)

or more generically...

   rep(df[,1], times=df[,2])

should work.

Cheerio,
Dan

Daniel Pritchard
PhD Student
Department of Botany
University of Otago
Dunedin, New Zealand

daniel.pritchard at botany.otago.ac.nz



On 6 Dec 2010, at 08:08, Ophelia Wang wrote:

> Hello,
>
> I have a list of species and abundance that looks like this:
>
> Aegiinte        3
> Agonperu      3
> Aiouimpr       2
> Albiniop        2
> Albisubd       1
> ..................
>
> And I need to convert these two columns into a column in which each
> cell represents an individual of a articular species:
>
> Aegiinte
> Aegiinte
> Aegiinte
> Agonperu
> Agonperu
> Agonperu
> Aiouimpr
> Aiouimpr
> Albiniop
> Albiniop
> Albisubd
> .........
>
> Can someone help me to develop a script to do the conversion?
>
> Thanks a lot!
>
> Ophelia
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



More information about the R-sig-ecology mailing list