merge_columns: rbind two or more data frames with different columns

Description Usage Arguments Value Examples

View source: R/merge_columns.R

Description

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

Usage

1

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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 documentation built on Jan. 8, 2020, 5:10 p.m.