[datatable-help] How to replace missing value with immediate matching/+-5 of corresponding previous value

srt123 kvsreddy.sas at gmail.com
Thu Jun 15 12:33:55 CEST 2017


Hi,
I have a data frame as below , how to replace NA values with immediate
matching value with col2 (eg. for row.id == 3 - if we round col2 value then
value is 36 and its immediate matching previous value is 35.96 and same for
row.id == 6 and row.id == 4)

row.id  date   col1    col2     
1 2014-02-28   23      38.1  
2 2014-02-26   20      35.96  
3 2014-02-27   NA      36.1       
4 2014-02-08   10      25.22  
5 2014-02-09   11      26.23  
6 2014-02-11   NA      25.10
output would be

row.id  date   col1    col2     
1 2014-02-28   23      38.1  
2 2014-02-26   20      35.96   
3 2014-02-27   20      36.1       
4 2014-02-08   10      25.22  
5 2014-02-09   11      26.23  
6 2014-02-11   10      25.10



--
View this message in context: http://r.789695.n4.nabble.com/How-to-replace-missing-value-with-immediate-matching-5-of-corresponding-previous-value-tp4738088.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list