add_columns {expss} | R Documentation |
Add columns to data.frame.
Description
add_columns
inspired by MATCH FILES (Add
variables...) from SPSS Statistics. It works similar to SQL left join but
number of cases in the left part always remain the same. If there are
duplicated keys in the y
then error will be raised by default.
Usage
add_columns(x, y, by = NULL, ignore_duplicates = FALSE, ...)
Arguments
x |
data.frame to be joined with |
y |
data.frame. |
by |
character vector or NULL(default) or 1. Names of common variables
in the |
ignore_duplicates |
logical Should we ignore duplicates in the |
... |
arguments for further methods |
Value
data.frame
Examples
# example for 'add_columns' from base 'merge'
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(
surname = c("Tukey", "Venables", "Tierney",
"Ripley", "Ripley", "McNeil", "R Core"),
title = c("Exploratory Data Analysis",
"Modern Applied Statistics ...",
"LISP-STAT",
"Spatial Statistics", "Stochastic Simulation",
"Interactive Data Analysis",
"An Introduction to R")
)
add_columns(books, authors)