cbind.fill: Combine arbitrary data types, filling in missing rows.

View source: R/row.r

cbind.fillR Documentation

Combine arbitrary data types, filling in missing rows.

Description

Robust alternative to cbind that fills missing values and works on arbitrary data types. Combines any number of R objects into a single matrix, with each input corresponding to the greater of 1 or ncol. cbind has counterintuitive results when working with lists, cannot handle certain inputs of differing length, and does not allow the fill to be specified.

Usage

## S3 method for class 'fill'
cbind(..., fill = NULL)

Arguments

...

any number of R data objects

fill

R object to fill empty rows in columns below the max size. If unspecified, repeats input rows in the same way as cbind.

Details

Originally written for the row.r package by Craig Varrichio. Included here because the rowr package was discontinued. I use these functions in my packages

Examples

cbind.fill(c(1,2,3),list(1,2,3),cbind(c(1,2,3)))
cbind.fill(rbind(1:2),rbind(3:4))
df<-data.frame(a=c(1,2,3),b=c(1,2,3))
cbind.fill(c(1,2,3),list(1,2,3),cbind(c('a','b')),'a',df)
cbind.fill(a=c(1,2,3),list(1,2,3),cbind(c('a','b')),'a',df,fill=NA)

ccpluncw/ccpl_R_chutils documentation built on Feb. 28, 2024, 1:17 a.m.