R ifelse condition: frequency of continuously NA
===

I'm new to R, and I was looking for similar questions, but was not able to find one to fix mine, any help would be appreciated!!
So I have this data frame M:
            date value
1 182-2002-01-01 23.95
2 182-2002-01-02 17.47
3 182-2002-01-03  NA
4 183-2002-01-01  NA
5 183-2002-01-02  5.50
6 183-2002-01-03 17.02
what I need to do is: if there are less than 5 NA (continuously), I will just repeat the previous number(17.47), and if there are more than 5 NA in a row, I will need to delete the whole month.
I tried function rle many times, but didn't work, many thanks for your help.