Hi, I need to write a function to use with calc (raster package) that replace the NA value of the raster with the value closest to it. Any suggestion on how to write it? thanks, Alfredo