Hi all,

I have a matrix of counts for objects (rows) by samples (columns).  I aimed
for about 500 counts in each sample (I have about 80 samples) and would now
like to rarefy these down to 100 counts in each sample using simple random
sampling without replacement.  I plan on rarefying several times for each
sample.  I could do the tedious looping task of making a list of all objects
(with its associated identifier) in each sample and then use the wonderful
"sampling" package to select a sub-sample of 100 for each sample and thereby
get a logical vector of inclusions.  I would then regroup the resulting
logical vector into a vector of counts by object, rinse and repeat several
times for each sample.

Alternately, using the same list, I could create a random index of integers
between 1 and the number of objects for a sample (without repeats) and then
select those objects from the list.  Again, rinse and repeat several time
for each sample.

Is there a way to directly rarefy a matrix of counts without having to
create a list of objects first?  I am trying to switch to R from Matlab and
am trying to pick up good programming habits from the start.

Much appreciation!

        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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