Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206736

Create in R a dataframe column that indicates how many times each row value has been sampled

$
0
0

I am using R to draw a random sample of 24 elements (species) out of a vector containing 36 elements. As I have to repeat this process several times, I would like to create a data frame in which the first column is the name of the species and the second is a counter of the number of times in which the species has been sampled. So, at the end of the first sampling i would have something like:

   Plot_1                      Freq   Agrostis castellana         1   Amaranthus hybridus         1   Ambrosia artemisiifolia     1   Bromus secalinus            0   ...                         ...

Then, after the second extraction I would have

   Plot_1                      Freq   Agrostis castellana         2      #extracted both in Plot1 and Plot2   Amaranthus hybridus         1      #extracted only in either Plot1 or Plot2   Ambrosia artemisiifolia     1   Bromus secalinus            0      #not extracted yet   ...                         ...

I've looked in the internet but I can't seem to find a solution :( Please help! Thank you very much!!


Viewing all articles
Browse latest Browse all 206736

Trending Articles