aggregate_with_criteria | R Documentation |
Often one needs to calulate the mean accepting certain number of missing values. For example, the World Meteorological Organisation specifies that monthly values must only be calculated if there is up to 10 missing days and less than 5 are consecutive. This function makes it easy to compute the monthly value by specifing these thresholds
aggregate_with_criteria(x, max_missing = 0, max_consecutive = 0,
fun = mean)
mean_with_criteria(x, max_missing = 0, max_consecutive = 0)
min_with_criteria(x, max_missing = 0, max_consecutive = 0)
max_with_criteria(x, max_missing = 0, max_consecutive = 0)
sum_with_criteria(x, max_missing = 0, max_consecutive = 0)
x |
Numeric values |
max_missing |
Numeric. Maximum number or proportion of missing values in x. If any number of missing values is allowed set to 1 (100%) or NULL. |
max_consecutive |
Numeric. Maximum number or proportion of consecutive missing values in x. If any number of missing values is allowed set to 1 (100%) or NULL. |
fun |
Function. Function used to aggregate values usually, mean, min, max, or sum |
NA if the criteria arent meet the mean of x otherwise
mean_with_criteria
: Mean with criteria
min_with_criteria
: Minimum with criteria
max_with_criteria
: Maximum with criteria
sum_with_criteria
: Sum with criteria
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.