R/clean_data_sp.R

Defines functions clean.data.sp

Documented in clean.data.sp

#' Clean sweetpotato data
#'
#' This is a wrapper for functions \code{setna.sp} and \code{setzero.sp} and
#' applies both in that order.
#' 
#' @param dfr The name of the data frame.
#' @param f Factor for extreme values detection.
#' 
#' @details The data frame must use the labels (lower or upper case) listed
#' in function \code{check.names.sp}. Then functions \code{setna.sp} and
#' \code{setzero.sp} are applied to the data.
#' 
#' @return It returns the data frame with all impossible values set to \code{NA},
#' some values set to \code{0} and a list of warnings with all the rows that have
#' been modified.
#' @author Raul Eyzaguirre.
#' @examples
#' dfr <- data.frame(crw = c(2.2, 5.0, 3.6, 12, 1600, -4, 0),
#'                   dm = c(21, 23, 105, 24, -3, 30, NA),
#'                   nocr = c(1.3, 10, 11, NA, 2, 5, NA),
#'                   scol = c(1, 0, 15, 5, 4, 7, NA),
#'                   fcol.cc = c(1, 15, 12, 24, 55, 20, NA))
#' clean.data.sp(dfr)
#' @importFrom stats IQR quantile
#' @export

clean.data.sp <- function(dfr, f = 10) {
  
  dfr <- setna.sp(dfr, f)
  
  dfr <- setzero.sp(dfr)
  
  # Return
  
  dfr
  
}
reyzaguirre/st4gi documentation built on April 30, 2024, 5:45 a.m.