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

Chris Howden chris at trickysolutions.com.au
Mon Dec 6 09:26:30 CET 2010


Hi Ophelia,

The way R references databases and columns might provide a solution.

So for the example below something like this might work.

Raw data set =
Aegiinte        3
Agonperu      3
Aiouimpr       2
Albiniop        2
Albisubd       1


Data <- raw[c(1,1,1,2,2,2,3,3,4,4,5),1]

If U have a very large species list then creating the
c(1,1,1,2,2,2,3,3,4,4,5) vector becomes quite tedious to do manually.

Not sure how u would 'automate' it, but u should be able to do it somehow.
Maybe using the rep() function.


Chris Howden
Founding Partner
Tricky Solutions
Tricky Solutions 4 Tricky Problems
Evidence Based Strategic Development, IP Commercialisation and Innovation,
Data Analysis, Modelling, and Training
(mobile) 0410 689 945
(fax / office) (+618) 8952 7878
chris at trickysolutions.com.au


-----Original Message-----
From: r-sig-ecology-bounces at r-project.org
[mailto:r-sig-ecology-bounces at r-project.org] On Behalf Of Ophelia Wang
Sent: Monday, 6 December 2010 5:39 PM
To: r-sig-ecology
Subject: [R-sig-eco] Converting species counts into species list

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