0

I have a dataset with many NAs. I want to use the number before the NA to replace it. Specifically,

Date Price
1    2.1
2    NA
3    2.4

I want to use '2.1' to replace the NA below it. I'm storing my data in a data.table and it contains 700 million observations. I know how to do it with a forloop, but it's taking a very long time. Is there a way to improve the speed?

Matt Dowle
  • 58,872
  • 22
  • 166
  • 224
user1691278
  • 1,751
  • 1
  • 15
  • 20

0 Answers0