On the web,i found that rbind()
is used to combine two data frames and the same task is performed by bind_rows()
function.
Then i don't understand what is the difference between these two functions and which is more efficient to use ??
On the web,i found that rbind()
is used to combine two data frames and the same task is performed by bind_rows()
function.
Then i don't understand what is the difference between these two functions and which is more efficient to use ??
Apart from few more differences, one of the main reasons for using
bind_rows
overrbind
is to combine two data frames having different number of columns.rbind
throws an error in such a case whereasbind_rows
assigns "NA
" to those rows of columns missing in one of the data frames where the value is not provided by the data frames.Try out the following code to see the difference:
Results for the two calls are as follows: