Last active
November 28, 2019 01:01
-
-
Save taddallas/df5c6af9fe49e7b94de076bfd8a24483 to your computer and use it in GitHub Desktop.
Relative abundance does what now!?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# my "true community" (a census) | |
comm <- sample(as.factor(letters[1:5]), 1000, | |
prob=c(0.6,0.4,0.2,0.1,0.1), replace=TRUE) | |
# taking random samples from my community and calculating relative abundance | |
samps <- plyr::ldply(1:1000, function(x){ | |
set.seed(x) | |
tmp <- table(sample(comm, 10)) | |
tmp <- tmp/sum(tmp) | |
return(tmp) | |
}) | |
# taking the mean of each relative abundance in the sample | |
colMeans(samps) | |
# I think I see what Andrew is saying!!! | |
rowMeans(samps) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment