I input 5 text data sets into R using read.table
.
Each data set has the same structure (100 rows, 50 cols).
I would like to union\append all the five tables together into one table, which will be 500 rows * 50 cols.
Anyone know how to do that?
The simplest way to combine two tables together is using the keywords UNION or UNION ALL. These two methods pile one lot of selected data on top of the other. The difference between the two keywords is that UNION only takes distinct values, but UNION ALL keeps all of the values selected.
To append data frames in R, use the rbind() function. The rbind() is a built-in R function that can combine several vectors, matrices, and/or data frames by rows. To join two data frames (datasets) vertically, use the rbind() function.
From package dplyr
:
install.packages('dplyr')
library(dplyr)
new_df <- bind_rows(table1, table2, table3, table4, table5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With