Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing all the Critical Points of datacleaner package for Quantargo training session. #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ Encoding: UTF-8
LazyData: true
Suggests:
testthat,
covr,
rmarkdown
RoxygenNote: 6.1.1
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you used roxygen2 to generate the NAMESPACE file?

4 changes: 4 additions & 0 deletions R/meanimpute.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#' Meanimputation
#'
#' Removes NA-s with the mean value for the vector \code{x}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces...

#'
#' @param x A numeric vector
#' @export
meanimpute <- function(x) {
x[is.na(x)] <- mean(x, na.rm = TRUE)
Expand Down
14 changes: 14 additions & 0 deletions R/transform_log.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#' Log Transform
#'
#' Transform numerical values into their log values.
#' @param x A numeric vector.
#' @return The log values of \code{x}.
#' @examples
#' transform_log(exp(rnorm(7)))
#' @export

transform_log<- function( x )
{
if( !is.numeric(x)) stop('Non numeric values found in passed paramenter.')
log(x )
}
16 changes: 13 additions & 3 deletions R/windsorize.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#' Windsorize
#'
#' Do some windsorization.
#' Replacing values of vector \code{x} greater or smaller then \code{q} quantile values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: ... than ...

#'
#' @param x A numerical vector.
#' @param p Quantile value for outliers removal.
#'
#' @examples
#' windsorize(c(1,499,500,501))
#' @export
#'
windsorize <- function(x, p = .90) {
q <- quantile(x, p)
x[x >= q] <- q
if(length(x) == 0) stop('Empty vector passed as an argument.')
if( sum(is.na(x)) == length(x) ) stop('A vector of NA-s passed as an argument')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More explicit to use if (all(is.na(x))) ...

q <- quantile(x, probs = c(1-p,p), na.rm = TRUE)
x[x >= q[2] ] <- q[2]
x[x <= q[1] ] <- q[1]
x
}

5 changes: 4 additions & 1 deletion man/meanimpute.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions man/transform_log.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion man/windsorize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.