zingle: Return the single (unique) value found in a vector

Description Usage Details

View source: R/base.R


Returns the first element in a vector, but only if all the other elements are identical to the first one (the vector only has a zingle value). If the elements are not all identical, it throws an error. The vector must contain at least one non-na value, or the function errors out as well.


zingle(x, na.rm = FALSE)


This is a useful function in aggregations when all values in a given group should be identical, but you want to make sure.

Optionally takes a na.rm parameter, similarly to sum, mean and other aggregate functions.

torfason/zulutils documentation built on May 20, 2019, 9:57 a.m.