Description Usage Arguments Details Value Examples

View source: R/countCropCycles.R

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

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

`x` |
Target numeric |

`min.length` |
Two element numeric |

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

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

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)
}
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.