Question:
I am trying to create a null bootstrap in R. The dataset has four species and associated sample values. I want to calculate themean
and a special poisson
function, sampling 5 values at a time from the distribution associated with each species. Here is my attempt at the code. I sampled 5 and tried to use summarise to calculate the mean and poisson function from those five values. I get an error that says ! New rows can't add columns.
Any suggestions on how to correct this to get the desrired output (attached).Answer:
The issue with error is based on the difference in column name in ‘output’ i.e.poisson.set
and in the for loop possion.set
. By correcting either one of them, it works (In addition, sp
was not created in the summarise
resulting in NA
)for
loop as well, i.e. group_by
the ‘sp’ column and use replicate/rerun
for multiple iterationsIf you have better answer, please add a comment about this, thank you!