Table 3: Output after row-binding Two Data Frames with the rbind.fill R Function. Rbind.fill(data_plyr1, data_plyr2) # Apply the rbind.fill plyr function fill (data_plyr1, data_plyr2 ) # Apply the rbind.fill plyr function In the following example, I’ll show you how to use the plyr rbind.fill function in R.Ĭonsider the following two example data frames: R usually returns the error “Error in match.names(clabs, names(xi))”, if you try to use the rbind function for data frames with different columns.įor that reason, the plyr package (be careful: it’s called plyr not dplyr) provides the rbind.fill R function as add-on to the rbind base function. The binding of data frames with different columns / column names is a bit more complicated with the rbind function. In the next example, I’m going to show you how to rbind data frames with different column names.Įxample 3: rbind fill – Row Bind with Missing Columns
When the columns of the two data frames differ, it gets a bit more complicated. Note: Both data frames have the same column names.
Table 2: Output after row-binding Two Data Frames in R.Īs in Example 1, the upper part of the rbind output consists of data_1 and the lower part of the rbind output consists of data_2. Rbind(data_1, data_2) # rbind two data frames in R Rbind (data_1, data_2 ) # rbind two data frames in R