2
我的數據有這樣的格式和命名的前框:填充特定列的數據幀
Day value1 value2
12-12-2012 00:00:00 1 1
12-12-2012 00:00:02 NA 2
12-12-2012 00:00:03 1 NA
12-12-2012 00:00:04 NA 4
12-12-2012 00:00:00 2 1
12-12-2012 00:00:02 NA 2
12-12-2012 00:00:03 2 NA
12-12-2012 00:00:04 NA 4
我想輸出是:
Day value1 value2
12-12-2012 00:00:00 1 1
12-12-2012 00:00:02 1 2
12-12-2012 00:00:03 1 NA
12-12-2012 00:00:04 1 4
12-12-2012 00:00:00 2 1
12-12-2012 00:00:02 2 2
12-12-2012 00:00:03 2 NA
12-12-2012 00:00:04 2 4
我試了一下:
fl = na.locf(ex$value1)
但問題是刪除了value2。如何在具有多列的框架中的特定列中使用na.locf並刪除它們?
locf是以前的值 –