0

I am doing this in R I have 2 dataframes A & B. A has 9 columns, while B has 8 columns which are in common. A consist of unique ID 1-500, while B consist of unique ID 501-1100.

I need to combine both the tables.

Please help me with the command. It would be great if multiple possible commands are told.

2

2 Answers 2

1

I would try to add a vector as a column with missing values to B and then just bind both datframes by rows:

empty<-c(NA * nrow(B))
cbind(B, empty)

rbind(A, B)
0

This can be accomplished in multiple ways using base functions and other packages:

You could try merge:

merge(x, y, by, by.x, by.y, sort = TRUE)

Dplyr:

And data.table. Example here.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.