1

I have large and a small table (in fact thousands of rows and columns).

E.g.

large <- data.frame(v1 = c(1,2,NA,4,NA,6,NA,NA),v2 = c("A","E","C","B","G","H","Z","Y"))

small <- data.frame(v3 = c("C","Y"), v4 = c("3.4","6"))    

Note the unique names in both tables. Ho can I fill up the values 3.4 and 6 into the column v1 from small$v4 without touching the rest?

> large
v1 v2
1  1  A
2  2  E
3 NA  C
4  4  B
5 NA  G
6  6  H
7 NA  Z
8 NA  Y



> small
v3  v4
1  C 3.4
2  Y   6

This should be the result:

> large.new
v1 v2
1 1.0  A
2 2.0  E
3 3.4  C
4 4.0  B
5  NA  G
6 6.0  H
7  NA  Z
8 6.0  Y

I tried merge() and match[] but they delete all the other data in the large columns ?!

Thank you, team !

  • Imagine a huge table full of data from single cars. With measurements, day of build, geodata of location, color, hp, etc. Then I sent a oil sample from 45 randomly selected cars to the lab. They return a table with the car plate an the data from lab oil measurements. Now. I want to fill the data to the large table. And 4 weeks later again, but from different cars with different plates but the same chemical measurements. I want to stepwise fill the large table... – Sascha Rösner Mar 16 '18 at 09:39
  • Hm, still trying hard. – Sascha Rösner Mar 18 '18 at 19:08

0 Answers0