Learn R Programming

ThomasJeffersonUniv (version 0.1.3)

mergeDF: An Alternative Merge Operation

Description

..

Usage

mergeDF(
  x,
  table,
  by = character(),
  by.x = character(),
  by.table = character(),
  ...
)

Value

Function mergeDF returns a data.frame.

Arguments

x

data.frame, on which new columns will be added. All rows of x will be retained in the returned object, in their original order.

table

data.frame, columns of which will be added to x. Not all rows of table will be included in the returned object

by

character scalar or vector

by.x, by.table

character scalar or vector

...

additional parameters of matchDF

Examples

Run this code
# examples inspired by ?merge.data.frame 

(authors = data.frame(
 surname = c('Tukey', 'Venables', 'Tierney', 'Ripley', 'McNeil'),
 nationality = c('US', 'Australia', 'US', 'UK', 'Australia'),
 deceased = c('yes', rep('no', 4))))
(books = data.frame(
 name = c('Tukey', 'Venables', 'Tierney', 'Ripley', 
  'Ripley', 'McNeil', 'R Core', 'Diggle'),
 title = c(
  'Exploratory Data Analysis',
  'Modern Applied Statistics',
  'LISP-STAT', 'Spatial Statistics', 'Stochastic Simulation',
  'Interactive Data Analysis', 'An Introduction to R',
  'Analysis of Longitudinal Data'),
 other.author = c(
  NA, 'Ripley', NA, NA, NA, NA, 'Venables & Smith',
  'Heagerty & Liang & Scott Zeger')))

(m = mergeDF(books, authors, by.x = 'name', by.table = 'surname'))
attr(m, 'nomatch')

Run the code above in your browser using DataLab