Returns the mean of a vector, matrix, or data.frame if it has nomiss proportion of valid cases
meanif(set, nomiss = 0.8, tr = 0)
A vector, matrix, or data.frame
A numeric vector specifying the proporiton of valid cases in set (i.e. data that must not be NA) for the mean to be returned
A numeric specifying the amount of trimming if desired
The built in r function mean includes an na.rm argument that allows the computation of a mean excluding missing cases. However, sometimes one wants to calculate the mean of an object so long as some proportion of those cases are present. The nomiss option of this function allows this capability. If fewer than the nomiss proportion of the cases are invalid (i.e. misssing) the function will return NA. Otherwise, it will return the mean of the valid cases.
Returns the mean.
Ryne A Sherman
1 2 3 4 5 6
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.