-
Notifications
You must be signed in to change notification settings - Fork 106
Description
I am using vegan 2.5-6 and R 3.6.3, .
In order to do some custom plots (with ggplot), I was investigating the format of the list invisibly returned by rarecurve(). My understanding is the sample name is stored as the name of the last item of the Subsample attribute - please correct me if I am wrong.
Then, trying to manipulate the list returned by rarecurve(), I discovered a weird random bug: sometimes, the Subsample attribute doesn't get the name of the original sample, and is not set at all - the plot, however, does show the sample name. The bug is somewhat random, affects some datasets but not others, and also depends on the step=150 parameter.
Reproducible example:
library( MASS )
set.seed( 2 )
m <- matrix( rnegbin( 80*4034, 15, 0.0005), 80, 4034 )
colnames( m ) <- paste0( "ASV", 1:4034 )
rownames( m ) <- paste0( "S", 1:80 )
prc <- vegan::rarecurve( m, step = 150, cex = 0.5 )
# with "step = 500" the bug is not triggered
Then:
names( attributes( prc[[1]] )$Subsample[
length( attributes( prc[[1]] )$Subsample ) ] )
returns, as expected, "S1", but:
names( attributes( prc[[17]] )$Subsample[
length( attributes( prc[[17]] )$Subsample ) ] )
returns NULL (with the above code, "S66" has also a NULL attribute name).
However, as I said, the plot returned do contain the label for "S17", which can be easily found on the plot bellow, as it is the uppermost sample name shown - "S66" is there as well, somewhere.
