countCropCycles: countCropCycles

Description Usage Arguments Details Value Examples

View source: R/countCropCycles.R

Description

Matches two vectors with different lengths based on their maximum value.

Usage

1
countCropCycles(x, min.length = c(1, 1))

Arguments

x

Target numeric vector.

min.length

Two element numeric vector.

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".

Value

A numeric element with the number of crop cycles in x.

Examples

1
2
3
4
5
6
7
8
9
{

x <- c(293, 770, 1166, 1166, 1562, 2357, 3234, 
5806, 5806, 5678, 5678, 5546, 5536, 5536, 5536, 
5325, 5200, 4726, 3550, 2868, 2365, 2365, 2365)

n <- countCropCycles(x)

}

RRemelgado/CAWaR documentation built on June 7, 2020, 10:27 p.m.