[R] Resample with replacement to produce many rarefaction curves with same number of samples

Nick Pardikes nickpardikes at gmail.com
Wed Sep 7 00:05:06 CEST 2016

I am currently having difficulty producing a graph using rarecurve in the
vegan package. I have produced rarefaction curves (seen below) using the
following code.


myMat <- round(matrix(rlnorm(2000), 50)) #creates distribution of

netdata <- as.data.frame(myMat) #generates a matrix of communities (rows),
species (columns)

raredata <- rarecurve(netdata, label=F, col=rgb(0, 0, 1, 0.1))  #uses
rarecurve to plot a rarefaction for each individual community (n=50)

However I would like to produce a graph in which all rarefaction curves end
at the same sample size. For example, in this graph it would be great to
extend the x-axis (sample size) to 100 and have all curves end at this
point. Is there any way to use rarecurve to resample a community (row) with
replacement the same number of times for all 50 communities? With
replacement is important because the communities differ greatly in their
size (number of species).

I understand that rarefaction is useful to compare communities with
different sample efforts, but I would still like to generate the figure. My
actual data has 5000 simulated communities that differ greatly in matrix
size and number of samples.

Thank you in advance for your help and suggestions.



Nick Pardikes
PhD Candidate
Program in Ecology, Evolution, and Conservation Biology
University of Nevada
*https://nickpardikes.wordpress.com/ <https://nickpardikes.wordpress.com/>*
nickpardikes at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rarefaction.pdf
Type: application/pdf
Size: 19167 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160906/b3b6dabe/attachment.pdf>

More information about the R-help mailing list