Matches two vectors with different lengths based on their maximum value.
Usage
countCropCycles(x, min.length = c(1, 1))
Arguments
x
Target numeric vector.
min.length
Two element numeric vector.
Value
A numeric element with the number of crop cycles in x.
Details
The function counts the number of value segments in x that are above its mean
effectively counting the number of crop cycles. Before reporting the final value, min.length
is used to filter outliers. The first element filters segments that lie below the mean (i.e. recently
cultivated/harvested). If the segment length is greater than the 1st element in min.length the
segment is relabeled as "1 (i.e. "crop growth/maturity". This process is repeated for segments above
the mean (i.e. crop growth/maturity). If the length of a segment is greater than the second element in
min.length it is labeled as "recently cultivated/harvested".