Description Usage Arguments Details Value Examples
This function allows you to generate a fixed subsample.
1 | rarify(inbug, sample.ID, abund, subsiz)
|
inbug |
data frame of SampleID, Count, and TaxaCode |
sample.ID |
data frame field with sample ID |
abund |
data frame field with number of individuals |
subsiz |
target subsample size |
rarify function: R function to rarify (subsample) a macroinvertebrate sample down to a fixed count; by John Van Sickle, USEPA. email: VanSickle.John@epa.gov ; Version 1.0, 06/10/05;
See rarify.help.txt for function documentation; See rarify.examples.r.txt for examples of usage; Modifications to generate reproducible subsamples. Set the seed for the random number generator to a fixed number. Erik.Leppo@tetratech.com (2016)
Returns the original data frame with an additional column for count
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # Location of files.
path <- getwd()
setwd(path)
library("MMIcalcNV")
# read in test data
#bugnew.raw <- read.csv(file="bugsamples.csv")
bugnew.raw <- NV.bugs
head(bugnew.raw)
#aggregate samples by bug code and sample
bugnew.raw <- bugnew.raw[,c("Samp_Rep","Individuals","TaxaID_Stage")]
bugnew.raw.ag <- aggregate(Individuals~TaxaID_Stage+Samp_Rep,data=bugnew.raw,sum)
#resample to 300 counts
bugnew.300cnt <- rarify(inbug=bugnew.raw.ag, sample.ID="Samp_Rep", abund="Individuals", subsiz=300)
# remove taxa with a count of zero
bugnew.300cnt <- bugnew.300cnt[bugnew.300cnt$Count>0,]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.