R/missingValuesColCompare.R

Defines functions missingValuesColCompare

Documented in missingValuesColCompare

#'missingValuesColCompare
#' @param searchDf a data.frame object which is to be searched for the missing values. 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 searchDfColIndex an integer indicating the column number of the column in \code{searchDf} in which the search has to be performed.
#' @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.
#' @param outputColNameVec a string or a vector of class character containing the column names from \code{searchDf} which are to be displayed in the output.
#' @return missingValuesColCompare returns the data.frame object \code{searchDf} with columns specified by \code{outputColNameVec} and rows corresponding to the locations of the missing values (i.e. values present in \code{dfColIndex1} of \code{dfData1} but not in \code{dfColIndex2} of \code{dfData2}) in column with number \code{searchDfColIndex} in \code{searchDf}
#' @description missingValuesColCompare takes as input a data.frame object (\code{searchDf}), the column number (\code{searchDfColIndex}) of a column in this data.frame object, column numbers (\code{dfColIndex1} and \code{dfColIndex2}) of two columns from two different data.frame objects (\code{dfData1} and \code{dfData2}) from which the missing values (i.e. values present in \code{dfColIndex1} of \code{dfData1} but not in \code{dfColIndex2} of \code{dfData2}) have to be identified, and a vector of column names from \code{searchDf} which are to be displayed in the output. The output is the data.frame object \code{searchDf} with rows given by row locations of the of the missing values in \code{searchDf} and columns specified by \code{outputColNameVec}. If \code{outputColNameVec} empty, all columns of \code{searchDf} will be displayed in the data.frame object returned. If \code{outputColNameVec} contains only one column, then the output is a vector of class gievn by the class of this one column.
#' @examples
#' employees_short <- employees[c(2,3,5),]
#' missingValuesColCompare(employees,4,employees,4,employees_short,4,c("start_date","salary"))
#' iris_short <- iris[c(50:75),]
#' missingValuesColCompare(iris,2,iris,2,iris_short,2,"Species")
#' @export
missingValuesColCompare<-function(searchDf,searchDfColIndex,dfData1,dfColIndex1,dfData2,dfColIndex2,outputColNameVec)
{
  units<-searchDf[loc.row(searchDf[,searchDfColIndex],
                           c(t(missingValuesCol(dfData1,dfColIndex1,dfData2,dfColIndex2)[2]))),outputColNameVec]
  return(units)
}
lwTools/agriTrf documentation built on March 26, 2020, 12:09 a.m.