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

0 votes

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 21, 2018 in Data Analytics by BHARANI
• 410 points
422 views

1 answer to this question.

0 votes

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 21, 2018 by Bharani
• 4,550 points

Related Questions In Data Analytics

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,020 points
39 views
0 votes
1 answer

Join list of data.frames using map() call

You can use Reduce set.seed(24) r1 <- map(c(5, 10, 15), ...READ MORE

answered Apr 5, 2018 in Data Analytics by darklord
• 6,170 points
26 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
124 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 4, 2018 in Data Analytics by Kalgi
• 41,990 points
59 views
0 votes
1 answer
0 votes
1 answer
+1 vote
2 answers
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 2, 2018 in Data Analytics by Bharani
• 4,550 points
163 views