0

I have a data1 with 95 columns Zero rows(empty data frame) and data2 with 53 columns 50 rows. Both data frames have same column names. I want 95 columns present in data1 with updated data2 column values remaining column values will be zero.

I have tried like below:

data1 <-ifelse(colnames(data2)%in%colnames(data1),data2,data1)

The output I am getting data2 with 53 columns. But, I want output as described above.

Please, help me through it.

Navya
  • 307
  • 3
  • 15
  • @Sotos , That link did not answered my question. Please, reopen the question or else You have to read again my post what am talking about. – Navya Jun 29 '20 at 08:00
  • Did I misunderstand your question? Maybe you should follow the guidelines of [how to ask a good question](http://stackoverflow.com/help/how-to-ask) and of course how to give a [reproducible example](http://stackoverflow.com/questions/5963269). In addition please add the expected output. Thanks – Sotos Jun 29 '20 at 08:07
  • @Sotos,Yes. I want to update column values in data1(only matched column values will be updated) from data2 remaining column in data1 will be 0. – Navya Jun 29 '20 at 08:12
  • Yeah, that is the definition of **merging**. Go through the links I gave you and restructure your question and If it is indeed another issue than merging then I will reopen – Sotos Jun 29 '20 at 08:15
  • @Sotos, Solved by myself without using merging. Thanks – Navya Jul 01 '20 at 18:58

0 Answers0