Skip to content

Commit

Permalink
windsorize() was corrected to do the necessary cheks on its allowed a…
Browse files Browse the repository at this point in the history
…rguments and to consider the smallest value of the vector. This fixes quantargo#15 & quantargo#16
  • Loading branch information
VilmaShehu committed May 4, 2019
1 parent e3f08e4 commit db76d37
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/windsorize.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
#' Do some windsorization.
#' @export
windsorize <- function(x, p = .90) {
q <- quantile(x, p)
if (length(x) == 0) stop("Not allowed the use of an empty vector!")
if (all(is.na(x))) stop("Not allowed the use of a vector containing only NA!")

q <- quantile(x, probs=c(1-p,p))
x[x >= q] <- q
x
}
Expand Down

0 comments on commit db76d37

Please sign in to comment.