R/rm.data.R

Defines functions rm.data

Documented in rm.data

#' Remove Poor Quality Data
#'
#' The function nulls values of the column 'O2.correct' for specified measurement phase(s) of a specified chamber in a data frame generated by the function \code{\link{correct.meas}}. As a result, those nulled data will not be available for futher steps of the analysis, particularly for the function \code{\link{extract.slope}}.
#'
#' @usage
#' rm.data(clean.data,
#'         chamber = c("CH1", "CH2", "CH3", "CH4",
#'                     "CH5", "CH6", "CH7", "CH8"),
#'         M.phase = "M0")
#'
#' @param clean.data  a data frame obtained by using the function \code{\link{correct.meas}}
#' @param chamber  string: the chamber where poor quality data were observed (must not contain multiple elements in a vector)
#' @param M.phase  string: the measurement phase(s) which should be eliminated from further steps of the analysis.
#'
#' @return The function returns a data frame containing data of metabolic rate measurements corrected for background respiration, where values of the column 'O2.correct' for exluded measurement phases were nulled. The data frame is used in the functions \code{\link{extract.slope}} and \code{\link{QC.slope}}.
#'
#' @examples
#' # if the data have been already loaded to R,
#' # skip the first line of the code:
#' data(AMR.clean)
#' AMR.clean.modified <- rm.data(AMR.clean,
#'                               chamber = "CH3",
#'                               M.phase = c("M1","M2"))
#'
#' @export

rm.data <- function(clean.data,
                    chamber = c("CH1", "CH2", "CH3", "CH4",
                                 "CH5", "CH6", "CH7", "CH8"),
                    M.phase = "M0"){

  for(i in 1:length(M.phase)){
    clean.data$O2.correct[clean.data$Chamber.No == chamber & clean.data$Phase == M.phase[i]] <- 0
    }
  return(clean.data)
  }

Try the FishResp package in your browser

Any scripts or data that you put into this service are public.

FishResp documentation built on Sept. 18, 2022, 5:06 p.m.