Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
exportPattern("^[[:alpha:]]+")
importFrom("stats", "quantile")
5 changes: 2 additions & 3 deletions R/meanimpute.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#' Meanimputation
#' @param x A vector
#' @export
meanimpute <- function(x) {
x[is.na(x)] <- mean(x, na.rm = TRUE)
x
}
x[is.na(x)] <- mean(x, na.rm = TRUE)
8 changes: 8 additions & 0 deletions R/transformlog.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
transform_log<- function(x){
if (x<0) stop("Negative input not allowed")
if (x==0) stop("Input 0 not allowed")
if (!is.numeric(x)) stop("Not numeric input not allowed")
if (is.null(x)) stop("NULL input not allowed")

log(x)
}
14 changes: 12 additions & 2 deletions R/windsorize.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#' Windsorize
#'
#' Do some windsorization.
#' @param x A numerical vector.
#' @param p Quantile value for outliers removal
#' @examples
#' windsorize(c(5,10,15,50))
#' @export
windsorize <- function(x, p = .90) {
q <- quantile(x, p)
x[x >= q] <- q
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) , na.rm = TRUE)
x[x >= q[2] ] <- q[2]
x[x <= q[1] ] <- q[1]
x
}