R/missingValuesCol.R

Defines functions missingValuesCol

Documented in missingValuesCol

#'missingValuesCol
#' @param dfData1 the first data.frame object. Note that this is not a character string but the data.frame object itself. The parameter passed to the function should be without quotes (" ").
#' @param dfColIndex1 an integer indicating the column number of \code{dfData1} to be handled. This column is one of the columns to be compared.
#' @param dfData2 the second data.frame object. Note that this is not a character string but the data.frame object itself. The parameter passed to the function should be without quotes (" ").
#' @param dfColIndex2 an integer indicating the column number of \code{dfData2} to be handled. This column is one of the columns to be compared.
#' @return missingValuesCol returns a data.frame object consisting of 2 columns 'placeinTable1' and 'rowName' indicating the row location and row name respectively of the missing values present in column number \code{dfColIndex1} in \code{dfData1} but not in column number \code{dfColIndex2} of code{dfData2}
#' @description missingValuesCol takes as input two data.frame objects (\code{dfData1}, \code{dfData2}), and two integer values (\code{dfColIndex1}, \code{dfColIndex2}) and returns a data.frame object with the row location and row name of the missing values present in column number \code{dfColIndex1} of \code{dfData1} but not in column number \code{dfColIndex2} of \code{dfData2}.
#' @examples
#' employees_short <- employees[c(2,3,5),]
#' missingValuesCol(employees,4,employees_short,4)
#' iris_short <- iris[c(50:75),]
#' missingValuesCol(iris,2,iris_short,2)
#' @export
missingValuesCol<-function(dfData1,dfColIndex1,dfData2,dfColIndex2)
{
  missingValuesColTab<-data.frame(placeInTable1=which(is.na(match(dfData1[,dfColIndex1],dfData2[,dfColIndex2]))),
                           rowName=dfData1[which(is.na(match(dfData1[,dfColIndex1],dfData2[,dfColIndex2]))),dfColIndex1])
  return(missingValuesColTab)
}
lwTools/agriTrf documentation built on March 26, 2020, 12:09 a.m.