Binding rows of 2 data-frames which have non-identical columns

+1 vote

Let's say i have these 2 data-frames:

abc
  name   salary age
1  raj 12345.55  36
xyz
  fruit cost quantity
1 apple  123       10

Now, if i use rbind, i get this error:

 rbind(abc,xyz)
Error in match.names(clabs, names(xi)) : 
  names do not match previous names

So, is there a way to bind the rows of these 2 columns/ 

May 22, 2018 in Data Analytics by BHARANI
• 420 points
6,052 views

1 answer to this question.

+1 vote

You can use the smartbind() function from 'gtools' package:

>library(gtools)
> smartbind(abc,xyz)
  name   salary age fruit cost quantity
1  raj 12345.55  36  <NA>   NA       NA
2 <NA>       NA  NA apple  123       10
answered May 22, 2018 by Bharani
• 4,660 points

Related Questions In Data Analytics

0 votes
1 answer

What if we have 2 columns with possible na rows?

Hi, You can do this in multiple ways. ...READ MORE

answered Oct 23, 2020 in Data Analytics by MD
• 95,460 points
1,071 views
0 votes
1 answer
0 votes
1 answer

How can I use parallel so that it preserves the list of data frames

You can use pmap as follows: nc <- ...READ MORE

answered Apr 4, 2018 in Data Analytics by kappa3010
• 2,090 points
1,077 views
+1 vote
1 answer

How to convert a list of vectors with various length into a Data.Frame?

We can easily use this command as.data.frame(lapply(d1, "length< ...READ MORE

answered Apr 4, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,669 views
0 votes
2 answers

In data frame how to spilt strings into values?

You can do this using dplyr and ...READ MORE

answered Dec 5, 2018 in Data Analytics by Kalgi
• 52,350 points
1,108 views
0 votes
1 answer
0 votes
1 answer
+1 vote
2 answers

Finding number of missing values and removing those missing values from a data-frame

To find number of missing values for ...READ MORE

answered Aug 14, 2019 in Data Analytics by anonymous
1,103 views
0 votes
1 answer

Building Random Forest on a data-set comprising of missing(NA) values

You have two options, either impute the ...READ MORE

answered Apr 3, 2018 in Data Analytics by Bharani
• 4,660 points
1,389 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP