R rbind example

By ganpati | R Programming

Jan 13

12rbind_img

rbind

What it does?
It adds the rows of the second data frame to the first data frame provided both data frames have same number of columns
Syntax:
print (data frame1, data frame2)
Example:
We have two dataframes samp1 and samp2 as below:
> samp1

col1 col2 col3

1 1 6 11
2 2 7 12
3 3 8 13
4 4 9 14
5 5 10 15
> samp2

col1 col2 col3

1 16 21 26
2 17 22 27
3 18 23 28
4 19 24 29
5 20 25 30
rbind(samp1, samp2)

col1 col2 col3

1 1 6 11
2 2 7 12
3 3 8 13
4 4 9 14
5 5 10 15
6 16 21 26
7 17 22 27
8 18 23 28
9 19 24 29
10 20 25 30

About the Author

Leave a Comment:

Leave a Comment: