0

I like to fill data.frames like

key val
"A"   2
NA    9 
NA    5 
"B"   5 
NA    1 
"C"   6 
NA    9 
NA    1 
NA    0 
NA    1 

with the "above" key instead of NA

key val
"A"   2
"A"   9 
"A"   5 
"B"   5 
"B"   1 
"C"   6 
"C"   9 
"C"   1 
"C"   0 
"C"   1 

I can go through each line per hand and save the last valid key, but that is very slow. Do you know a efficient way? Perhaps with dplyr?

Thank you very much

Vitor Canova
  • 3,918
  • 5
  • 31
  • 55
ckluss
  • 1,477
  • 4
  • 21
  • 33

0 Answers0