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

Jim Lemon drjimlemon at gmail.com
Wed Sep 7 12:21:17 CEST 2016


Hi Nick,
This is pretty rough, but it may help:

pdf("rd.pdf")
raredata<-rarecurve(cbind(netdata,netdata,netdata),label=FALSE,
 col=rgb(0,0,1,0.1),xlim=c(0,100),ylim=c(0,80))
rect(100,0,104,80,col="white",border=NA)
dev.off()

Jim

On Wed, Sep 7, 2016 at 8:05 AM, Nick Pardikes <nickpardikes at gmail.com> wrote:
> 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.
>
>
> library(vegan)
>
> myMat <- round(matrix(rlnorm(2000), 50)) #creates distribution of
> communities
>
> 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.
>
>
> Cheers,
>
> Nick
>
> --
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rd.pdf
Type: application/pdf
Size: 28579 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20160907/13ed22e5/attachment.pdf>


More information about the R-help mailing list