0

I am having multiple csv files imported(files all are in same directory) into R with different number of columns.How can I combine them in to single data frame?

one category of file Second category of file

I would like to have a single dataframe like biomarkers and allclinical.

Doing Column bind I will end up with a huge number of columns where as with row bind null values and data redundancy would occur.

whats the best way to deal with this solution. regards, akshay

2
  • do they all have the same headings? What is the structure of the contents? If they are the same, read them all in, then use rbind or merge to join them all Commented Feb 22, 2019 at 4:27
  • @RAB no they donot have same headings they are different Commented Feb 22, 2019 at 6:27

1 Answer 1

2

use

library(gtools)
df_combines <- smartbind(df1,df2,df3......)

good thing about gtools is that it will append all the data with same column name and only if the column name does not match it will add a new column to the final combined data frame .

Sign up to request clarification or add additional context in comments.

1 Comment

if this or any answer has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.