mergev: mergev

View source: R/mergev.R

mergevR Documentation

mergev

Description

More verbose merge function

Usage

mergev(
  x,
  y,
  by = NULL,
  by.x = NULL,
  by.y = NULL,
  all.x = NULL,
  all.y = NULL,
  all = FALSE,
  order = c("sort", "unsorted", "x", "y"),
  fast = FALSE,
  merge.type.colname = "merge.type",
  return.list = FALSE,
  verbose = TRUE,
  showWarnings = TRUE,
  ...
)

Arguments

x

first data.frame to merge, same as in merge.

y

second data.frame to merge, same as in merge.

by

character vector of column names to merge by. When by is used, the column names must be the same in x and y. Silently overrides by.x and by.y

by.x

character vector of column names on x to merge by. The resulting file will have these names.

by.y

character vector of column names on y to merge by.

all.x

logical value indicating if unmerged rows from x should be included in the output.

all.y

logical value indicating if unmerged rows from y should be included in the output.

all

logical value indicating if unmerged rows from x and y should be included in the output. Silently overrides all.x and all.y.

order

character string from "sort", "unsorted", "x", and "y". Specifies the order of the output. Setting this to "sort" gives the same result as merge with sort=TRUE. unsorted gives the same result as sort=FALSE. "x" and "y" sort by the incoming sort order of x and y, respectively.

fast

logical value indicating if data.table should be used to do the merge.

merge.type.colname

character indicating the column name of the resulting merge type column. See description.

return.list

logical value indicating if the merged data.frame and verbose output should be returned as elements of a list. Defaults to FALSE where the function simply returns a data.frame.

verbose

logical value indicating if output should be reported. Defaults to TRUE. Useful for testing.

showWarnings

logical value to output warning messages (TRUE) or suppress (FALSE). Defaults to TRUE.

...

additional parameters passed to merge.

Details

This is a wrapper for the base package merge function that prints out verbose information about the merge, including the merge type (one/many to one/many), the overlapping column names that will have suffixes applied, the number of rows and the number of unique keys that are in each dataset and in the resulting dataset.

Also gives more detailed errors when, e.g. the columns named in the by argument are not on the x or y data.frames.

Value

depends on the value of return.list.

When return.list is FALSE, returns a data.frame.

When return.list is TRUE, returns a list with two elements. The first is the same data.frame result. The second is a list with the values that were printed out. Elements include merge.type with two elements, each "one" or "many" indicating the merge type for x and y, respectively; inBoth, the list of column names in both merged data.frames; and merge.matrix the matrix printed out by this function.


EdSurvey documentation built on June 27, 2024, 5:10 p.m.