Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

merge_columns

rbind two or more data frames with different columns


Description

Take two data.frames with arbitraily different numbers and names of columns, and rbind them together.

Usage

merge_columns(x, y)

Arguments

x

A data.frame, or a list containing multiple data.frames.

y

An optional second data.frame. Only used if x is not a list.

Value

An object of class 'data.frame', containing data from all input data frames. That is, all unique columns are preserved, while rows that are missing data for a given column are assigned NA.

Examples

# import some data
file_location <- system.file(
  "extdata",
  "avian_ecology_bibliography.ris",
  package = "revtools")
x <- read_bibliography(file_location)
y <- x[, 1:3]
z <- merge_columns(x, y)
# or equivalently
z <- merge_columns(list(x, y))

revtools

Tools to Support Evidence Synthesis

v0.4.1
GPL-3
Authors
Martin J. Westgate [aut, cre]
Initial release
2019-12-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.