Quickly row and column bind many objects together at once

Description

A wrapper for rbind and cbind to quickly bind numerous objects together at once using a single call to rbind or cbind. This function is most helpful when there are many objects to bind and the object names are easily represented in text.

Usage

1
qbind(objects, type = c("row", "col", "c"))

Arguments

objects

A character vector with the names of the objects to be bound together

type

The type of binding, "row" for rbind or "col" for cbind, and "c" for concatenating using c. Defaults to "row".

Value

The bound object

Author(s)

Landon Sego

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Row binding
a1 <- data.frame(a = 1:3, b = rnorm(3), c = runif(3))
a2 <- data.frame(a = 4:6, b = rnorm(3), c = runif(3))
a3 <- data.frame(a = 7:9, b = rnorm(3), c = runif(3))

qbind(paste("a", 1:3, sep = ""))

# Column binding
b1 <- matrix(1:9, nrow = 3, dimnames = list(1:3, letters[1:3]))
b2 <- matrix(10:18, nrow = 3, dimnames = list(4:6, letters[4:6]))
b3 <- matrix(19:27, nrow = 3, dimnames = list(7:9, letters[7:9]))

qbind(paste("b", 1:3, sep = ""), type = "col")

# Concatenating a vector
a1 <- c(x = 1, y = 2)
a2 <- c(z = 3, w = 4)

qbind(c("a1", "a2"), type = "c")

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.