This question already has an answer here:
- Replacing NAs with latest non-NA value 13 answers
Say you have something like this across various weeks in a given df:
DoW Value
Mon 1234
Tue NA
Wed 5678
Thu 9123
Fri 4567
Sat 8912
Sun 3456
I'd like to fill every Tuesday's NA with Monday's value of it's correspondent week. How can I do this, preferably with the least amount of code possible?
Thanks.
What about this ?
You can also do this with the
tidyr::fill
.