rbinds a list of data frames filling missing columns with NA.

rbind.fill(...)

Arguments

...

input data frames to row bind together. The first 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 NULL.

Value

a single data frame

Details

This is an enhancement to rbind that adds in columns that are not present in all inputs, accepts a list 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.

See also

Other binding functions: rbind.fill.matrix()

Examples

rbind.fill(mtcars[c("mpg", "wt")], mtcars[c("wt", "cyl")])
#>     mpg    wt cyl
#> 1  21.0 2.620  NA
#> 2  21.0 2.875  NA
#> 3  22.8 2.320  NA
#> 4  21.4 3.215  NA
#> 5  18.7 3.440  NA
#> 6  18.1 3.460  NA
#> 7  14.3 3.570  NA
#> 8  24.4 3.190  NA
#> 9  22.8 3.150  NA
#> 10 19.2 3.440  NA
#> 11 17.8 3.440  NA
#> 12 16.4 4.070  NA
#> 13 17.3 3.730  NA
#> 14 15.2 3.780  NA
#> 15 10.4 5.250  NA
#> 16 10.4 5.424  NA
#> 17 14.7 5.345  NA
#> 18 32.4 2.200  NA
#> 19 30.4 1.615  NA
#> 20 33.9 1.835  NA
#> 21 21.5 2.465  NA
#> 22 15.5 3.520  NA
#> 23 15.2 3.435  NA
#> 24 13.3 3.840  NA
#> 25 19.2 3.845  NA
#> 26 27.3 1.935  NA
#> 27 26.0 2.140  NA
#> 28 30.4 1.513  NA
#> 29 15.8 3.170  NA
#> 30 19.7 2.770  NA
#> 31 15.0 3.570  NA
#> 32 21.4 2.780  NA
#> 33   NA 2.620   6
#> 34   NA 2.875   6
#> 35   NA 2.320   4
#> 36   NA 3.215   6
#> 37   NA 3.440   8
#> 38   NA 3.460   6
#> 39   NA 3.570   8
#> 40   NA 3.190   4
#> 41   NA 3.150   4
#> 42   NA 3.440   6
#> 43   NA 3.440   6
#> 44   NA 4.070   8
#> 45   NA 3.730   8
#> 46   NA 3.780   8
#> 47   NA 5.250   8
#> 48   NA 5.424   8
#> 49   NA 5.345   8
#> 50   NA 2.200   4
#> 51   NA 1.615   4
#> 52   NA 1.835   4
#> 53   NA 2.465   4
#> 54   NA 3.520   8
#> 55   NA 3.435   8
#> 56   NA 3.840   8
#> 57   NA 3.845   8
#> 58   NA 1.935   4
#> 59   NA 2.140   4
#> 60   NA 1.513   4
#> 61   NA 3.170   8
#> 62   NA 2.770   6
#> 63   NA 3.570   8
#> 64   NA 2.780   4