I have a raster image for which I would like to interpolate the values for NA only. The missing NA's are usually in the border of the image. I am fairly new to R so I am not sure how exactly to do it. The accuracy of the values doesn't have to be higher and I would like to do just nearest neighbour interpolation. Any helps and suggestions or welcome. I have added a simplified code to genetae a raster which has NA values on the border but ideally this NA value would be on all 4 sides of the raster. I found a post similar to filling NA gaps Fill in gaps (e.g. not single cells) of NA values in raster using a neighborhood analysis but it doesnt work for me.
rast <- raster(nrow=10, ncol=10, crs='+proj=utm +zone=1 +datum=WGS84', xmn=0, xmx=1, ymn=0, ymx=1)
values(rast) <- 1:ncell(rast)
values(rast)[1:20] <- NA