df.rbind: Combine Data Frames by Rows, Filling in Missing Columns

View source: R/df.rbind.R

df.rbindR Documentation

Combine Data Frames by Rows, Filling in Missing Columns

Description

This function takes a sequence of data frames and combines them by rows, while filling in missing columns with NAs.

Usage

df.rbind(...)

Arguments

...

a sequence of data frame to be row bind together. This argument can be a list of data frames, in which case all other arguments are ignored. Any NULL inputs are silently dropped. If all inputs are NULL, the output is also NULL.

Details

This is an enhancement to rbind that adds in columns that are not present in all inputs, accepts a sequence of data frames, and operates substantially faster.

Column names and types in the output will appear in the order in which they were encountered.

Unordered factor columns will have their levels unified and character data bound with factors will be converted to character. POSIXct data will be converted to be in the same time zone. Array and matrix columns must have identical dimensions after the row count. Aside from these there are no general checks that each column is of consistent data type.

Value

Returns a single data frame

Note

This function is a copy of the rbind.fill() function in the plyr package by Hadley Wickham.

Author(s)

Hadley Wickham

References

Wickham, H. (2011). The split-apply-combine strategy for data analysis. Journal of Statistical Software, 40, 1-29. https://doi.org/10.18637/jss.v040.i01

Wickham, H. (2019). plyr: Tools for Splitting, Applying and Combining Data. R package version 1.8.5.

See Also

df.duplicated, df.unique, df.merge, df.rename, df.sort

Examples

adat <- data.frame(id = c(1, 2, 3),
                   a = c(7, 3, 8),
                   b = c(4, 2, 7))

bdat <- data.frame(id = c(4, 5, 6),
                   a = c(2, 4, 6),
                   c = c(4, 2, 7))

cdat <- data.frame(id = c(7, 8, 9),
                   a = c(1, 4, 6),
                   d = c(9, 5, 4))

df.rbind(adat, bdat, cdat)

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to df.rbind in misty...