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

cbindX

Column-bind objects with different number of rows


Description

cbindX column-binds objects with different number of rows.

Usage

cbindX(...)

Arguments

...

matrix and data.frame objects

Details

First the object with maximal number of rows is found. Other objects that have less rows get (via rbind) additional rows with NA values. Finally, all objects are column-binded (via cbind).

Value

See details

Author(s)

Gregor Gorjanc

See Also

Regular cbind and rbind

Examples

df1 <- data.frame(a=1:3, b=c("A", "B", "C"))
df2 <- data.frame(c=as.character(1:5), a=5:1)

ma1 <- matrix(as.character(1:4), nrow=2, ncol=2)
ma2 <- matrix(1:6, nrow=3, ncol=2)

cbindX(df1, df2)
cbindX(ma1, ma2)
cbindX(df1, ma1)
cbindX(df1, df2, ma1, ma2)
cbindX(ma1, ma2, df1, df2)

gdata

Various R Programming Tools for Data Manipulation

v2.18.0
GPL-2
Authors
Gregory R. Warnes, Ben Bolker, Gregor Gorjanc, Gabor Grothendieck, Ales Korosec, Thomas Lumley, Don MacQueen, Arni Magnusson, Jim Rogers, and others
Initial release
2017-06-05

We don't support your browser anymore

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